Unreal Engine 4.23.0 C++
When running the function BeginPlay(), my member variable _initialTransforms nicely fills in everything as expected, but the moment I'm going out of the scope of the BeginPlay() function and into the DrawRobot(...,...) function _initialTransforms loses its values and just becomes an empty TArray again. I checked if I accidentally changed its values in another function, but these are the only references of _initialTransforms in the project. The class derives from 'AActor', and the object is created out of a possessed 'pawn'. The object doesn't get recreated since its constructor doesn't run twice. Does anyone have an idea why this happens? Thank you!
The reduced version of the code below.
Header file
protected:
TArray<FMatrix> _initialTransforms;
cpp file
void ARobot::BeginPlay()
{
Super::BeginPlay();
TArray<float> zeroArray;
zeroArray.Init(0, 6);
Forward(zeroArray, _initialTransforms);
}
void ARobot::Forward(TArray<float> jointsDeg, TArray<FMatrix>& m)
{...
}
void ARobot::DrawRobot(TArray<float> jointsDeg)
{
Forward(jointsDeg, _currentPose);
FTransform baseTransform = FTransform(ToLeftHanded(_currentPose[0] * _initialTransforms[0].Inverse()));
... }