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?
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