How to control Order of Components (C++) in Blueprint's Components Tab?

Hi there,

I have actually three related questions:

  1. How am I able to control Order of Components (C++) in Blueprint’s Components Tab?
  2. What is preferred the preferred way to attach UActorComponents, MyComponent->RegisterComponent() or AddOwnedComponent(MyComponent)?
  3. Why is Unreal getting confused with UCombatComponents, e.g. why is in the BP 2nd Melee (3rd Melee) even though it is declared as Melee2nd = CreateDefaultSubobject<UCombatComponent>(TEXT("2nd Melee"));? Is this worth a bugreport? See screenshot:

Thanks in advance!

If you are creating component in the CDO (objects constructor) then do not call RegisterComponent() it will throw an error. (only use it in the case of newObject outside of the constructor).

Perhaps registerComponent is messing with the order. it is not needed here (it’s called automatically)

The preferred way would be

  • x = CreateDefaultSubObject…
  • x->c->SetupAttachment(parent) e.g. GetRootComponent() if actor

Hey 3dRaven,

there is no UActorComponents::SetupAttachment(parent). This only exists for USceneComponents.

I think AddOwnedComponent(MyActorComponent) is the way to go. In a previous version I only used this to attach all UActorComponents leading to the wrong order and naming.

What is would be the correct way to realize this?