Yes, define a TObjectPtr<USceneComponent>
in your header file and initialize it with CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
in your actor’s constructor.
Use SetRootComponent
function after to set it as the root (although I think the first call of CreateDefaultSubobject might do that implicitely).
Then, when you initialize your other components with their own call to CreateDefaultSubobject
, use SetupAttachment(GetRootComponent())
. to parent them all to a common root.
Just a note, however:
I’m not sure what you are saying with ActorComponent since ActorComponent are non-physical and cannot be represented in the world/attached to other components. Make sure you are using SceneComponents for that?