Components Within Components...

I’ve created a custom UActorComponent, which has it’s own constructor and creates a Spring Arm and Camera as part of that Component. It then attaches these to it’s owners RootComponent in code.

I have two major issues, the first is that if the RootComponent of the owner simulates physics, then the whole actor ends up being rapidly culled/removed from the world by the Engine with this component attached to it. The second, is that I trigger a breakpoint in the Constructor where the SpringArm is attached to the Owner’s Root Component. Play continues just fine, but it still triggers just the same.

Apparently the latter issue is related to trying to attach a template component to an instanced one or something…

So… any ideas?

Okay… called the parenting of the sub-components from the Owning Actor, and that seemed to fix both issues.

Can’t help but feel this is really dodgy though… are Sub-Components inside Actor Components supported or have I just botched it?

They can work in singleplayer, they won’t work in multiplayer.

I had the template instance breakpoint as well. Solved it by storing all created components in fields marked as UPROPERTY.

UE supports components being children of other components, so whether you construct that hierarchy from the outside (the actor constructor for example) or the inside (custom component constructor) makes no difference.

What does matter is that you need to store pointers to them as uproperty. UE needs that metadata to know that its values should be saved and possibly for replication as well. Are you storing them like that? If not that may fix the breakpoint issue.

Edit: oh nice that you solved it. :slight_smile:

Interesting! Unfortunately my fix was only temporary, I soon got crashes in the editor whenever I made ALT+DRAG instances of the actor in the level, I’ve since messed with my code so much that it’s almost not the same. Thanks for the tip though, I’ll certainly try that next time!

I am trying to switch over to using the PlayerCameraManager class and creating a springarm & camera component as part of the Player Controller. The CamManager just reads in the values for the location/length of the arm if the Possessed Pawn has a certain ActorComponent that stores the variables. There’s a lot of pointing/casting going on, I’m starting to wonder if it’s going to make things a bit slow. It also means overriding a lot of the base functions which I really want to avoid, as it means I may have to change huge chunks of code later. Might end up going back to UPROPERTY if I can figure out the ALT+DRAG crash!