Location-only SceneComponent as Actor root

Is there a way to have the root component of an actor be just a location?

The actor has several ActorComponents (with child components themselves) which move independently from each-other. Is there a way to have a common root component that can be used to position and rotate the whole group of ActorComponents but which itself has no mesh, extent or other code associated with it? Just a location that can act as a parent for the other components?

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?

1 Like