How does Component Hierarchy work in C++?

Hey guys,

I have an issue where I try to create Default subcomponents in the Constructor of a custom component:
For Example:

    BoxCollision = CreateDefaultSubobject<UBoxComponent>(TEXT("BoxCollision"));

Almost everything works fine. The box collision is spawned and attached to the UCustomComponent (BaseClass is Scenecomponent)
but the Problem is that when I have multiple UCustomComponents in an Actor the References of the components collide and some Components have references to members of others.
It’s a really weird issue and I’m very frustrated because I spent so much time Setting everything up.
I looked through the Engine source code and could not find anything which helps me.

There has to be a way to get this to work.

Thanks in advance for you help :slight_smile:

I resolved the Issue.
I attached multiple CustomComponent to my Actor but the Name of the BoxCollision where everytime the same.
Because all BoxCollision shared the same Name AND Root there were a mixup.