I have a Problem with the RootComponent of a class. I try to Get Access of the RootComponent of an AActor with GetRootComponent. Before I tried this I set a BoxComponent as RootComponent. But if I want to get access of the Root I ever get a nullptr. How can I access the RootComponent, because I want to add a force to the object but it doesn’t work without access to the Root.
Short Example Code:
class UBoxComponent* m_RootComponent;
m_RootComponent = CreateDefaultSubobject(“RootComponent”);
//some other Stuff to configure the RootComponent
RootComponent = m_RootComponent;
UBoxComponent* box = GetRootComponent(); // I tried this, because the Root is a box
USceneComponent* root = GetRootComponent(); //I tried this, because the output of GetRootComponent is a USceneComponent
OtherTestClass.cpp (inherits from Test.h)
UBoxComponent* box = GetRootComponent();
USceneComponent* root = GetRootComponent();
The methods under the Constructor are my tries to get access to the RootComponent, but every try gives me an error with a nullptr. How can i fix it to add a force to this actor ?