Issue with Components that create subcomponents in their constructor with CreateDefaultSubobject

Is it possible to create a component that has 2 sub-components in native code using the constructor? My current scenario is I have a child of UMotionControllerComponent that pre-creates 2 subcomponents in it’s constructor using CreateDefaultSuboject (a USkeletalMeshComponent and a USphereComponent). Both of the subcomponents are attached to the their owner (the UMotionControllerComponent).

The problem I’m running in to is when I add my UMotionControllerComponent’s to my Character’s sub-components in it’s constructor using CreateDefaultSubobject neither of the two sub-components are editable in the editor. And if I add a second of my UMotionControllerComponent, the object hierarchy breaks altogether. Maybe because the 2 auto-created sub components share the same name so the hierarchy stacks them under the first UMotionControllerComponent. It’s worse if I try to add the via the add component button in the editor…

I’m guessing that I’m just breaking the paradigm for using components here. I can solve this in order ways but this seems like a case that should work. Am I just missing something?

did you trying to use “AttachToComponent”? and attach it to component you are in

The sub-components are already attached to this (the UMotionControllerComponent) which is then, in the Character, attached to my UCameraComponent.

I’m currently implementing some sub components and am facing a few issues too, so I can partly reply to your question
It seems that unreal does not support having two components (or sub components) that have the same name
To solve this, when you create your subcomponent, prefix its name with the parent component’s name.

But in the end, the editor will never show the details of your subcomponents when you select them
If you store them with the property specifier EditAnywhere, you will be able to edit all of their properties from the parent components details panel

Similar question: Unreal Engine 4.25.4 - CreateDefaultSubobject inside a child component attached to an actor loses values in blueprint editor - Programming & Scripting - Unreal Engine Forums - I have the same problem. I have also thought about abandoning this, but it does make a lot of sense that it should work.

this is not the same issue @jimmyt1988, here is about having no properties at all in a component in a component, your question is an issue about one single parameter missing in a component