Can a component contain other components?
I've been trying to break an ACharacter based class down into several UActorComponent based classes contained within an ACharacter class in order to reduce redundancy and simplify adding new features to the character class. Several of these custom components contain pointers to other components, such as SphereComponents and SceneComponents.
I thought this was OK, since the documentation for components mentions that a car actor might have separate components for its doors and tires. However, the custom components are behaving oddly, and I have described their behavior here. A reply to my question suggested using true for the argument bTransient might fix this problem. However, since doing so, I am getting this error:
Which leads me to believe that what I am trying to do isn't possible. However, I found more information in the documentation suggesting that the earlier behavior I mentioned could be due to the fact that Components are only instanced from within an actor, and I thought that applying this property to my subobjects might fix the problem. However, my game still crashes when trying to CreateDefaultSubobject when bTransient is set to true. Even after removing "true" from all of my CreateDefaultSubobject calls, I still get the error. So is what I am trying to do even possible? If you need more information, please let me know and I would be happy to provide what I can.
EDIT: For clarification, the hierarchy is that the Character contains a custom component called ArmComponent, this component contains 2 sphere components which are constructed during the construction of ArmComponent, then attached to a bone on the mesh of the Character class. They construct fine, but by the time TickComponent is reached, one of the things I have described above or in a comment below has happened. Is it possible to have a subcomponent of a component which is not attached to said component without this happening?
Follow this question
Once you sign in you will be able to subscribe for any updates here