Unable to find USpringArmComponent attatched to parent object

Hi Guys,

I am currently attempting to reference an attached spring arm that is a child component of an actor. See image:

85895-0_heirarchy.png

From the UOrbitalCamera class, I have declared a pointer to the Spring Arm like this:

85896-0_header.png

In the beginplay function, I attempt to find the SpringArm, and added some validation to protect against a null pointer. It compiles fine, and When i run the game, I can see the output confirming that a SpringArm has been found.

I have another, public function called “Zoom”. This is called from another class. I have confirmed that the function is being called successfully, because of the UE_LOG output during runtime. However, at this point it appears as though the pointer has reverted to a null pointer??? The validation prevents a crash but If i remove it, the editor crashes, and I assume that I encounter a nullptr ex…

I really have no idea why this isn’t working, I am new to C++ and may have missed something but this does not seem to be the case…

It might be worth noting that when I tried to expose SpringArm as a UPROPERTY(EditAnywhere) and reference the component in the editor, there was no SpringArm available in the drop-down menu. Maybe that is related.

Thanks,
S

EDIT: I figured this one out myself.

I got a clue when I realised that my variables were resetting themselves during run-time.

The class from which I was calling the Zoom function, had a reference to this (UOrbitalCamRig) as a TLazyObjecPtr. I dont know enough about c++ yet to understand why it was screwing it up, but it was… I guess it really is a lazy pointer!!!

Either way, I switched it over to a normal pointer and located this class using the actor iterator (LINK). It all works now.