Hi have an Actor that creates several UStaticMeshComponent’s and adds them to the RootComponent in the OnConstruction function. Additionally I add the pointers to these UStaticMeshComponent’s to a private member variable of type TArray.
UCLASS()
class MYPROJECT_API AMyActor : public AActor
{
GENERATED_BODY()
...
private:
TArray<UStaticMeshComponent*> m_aMeshComponents;
};
Once BeginPlay is called this array is empty while the components still exists as children under the RootComponent.
Why is this array cleared and how can I prevent it? I need to iterate over these during play and don’t want to iterate the RootComponent’s children as they also contain other components.
Thanks in advance
James
EDIT:
It appears all my private member variables get reset by the time BeginPlay runs. I have a stored float that is filled with info also in the OnConstruction which is reset to zero somewhere.