LandscapeSplineComponent Crashing on dereference (C++)

Mrjamesgaming
Wed, 14 Feb 2024 15:35:20 +0000
C++

Hello all,
I am fairly new to Unreal Engine and C++ in general. I am making a racing game and using the vehicle template as a jumping point for my project, I wanted to get a reference to the landscape spline that the editor used to construct the track but I have been having some trouble. After a lot of sleuthing, I found a solution through this Pastebin scrolling down to the bottom of the comment section you find the 2 lines of code here,
ULandscapeSplinesComponent* LandscapeSplineComponent = Landscape->SplineComponent;
LandscapeSplineComponent->CopyToSplineComponent(SplineComponent);

I implemented that in a custom wrapper class to grab the spline for me but everytime I initalize it and attempt to dereference the ULandscapeSplineComponent that is initialized here I end up with a crash.
Here is my .cpp file

here is my .h file

the top line is just a #pragma once line

anyways the crash occurs on line 53 in the .cpp file. the program runs stable if I have that line commented, this is the output log when I run it with the line commented out

however, upon running with the line uncommented I am immediately met with this crash message on play

I’m aware that it is accessing an illegal location in memory, I dont know if there is an explicit way to mitigate that with cpp, I know some other forums I read mentioned something about GPU drivers being out of date but that was when the memory address was pointing to 0x000000000000000 which I assumed was a nullspace and based on the memory address I am pretty sure my issue is different(?). I have tried restarting my computer, but that did nothing, updated my OS (since I was running an old version of Windows 11).

Additional specs:
Engine: Unreal Engine 5.3.2
CPU: AMD Ryzen 9 7945HX
GPU: RTX 4060 Laptop GPU
OS: Windows 11 Home
Ram: Crucial 32GB DDR5-5600 SODIMM (not factory ram but compatible)
Laptop Model: ASUS ROG Strix G17 G713PV-DS94

Any other additional information id be happy to provide. Thanks in advance
-James

5 posts - 3 participants