Download

Question about Component Nesting / Construction

I’m trying to do something that is just a little outside the normal UE4 workflow and I’m struggling to find a paradigm that makes sense for it with actors and components.

I want to have a base object, with some functionality that represents a Camera and contains a Spring Arm component and a Camera component, with the Camera parented under the spring arm. I want users to be able to add this to Blueprints and in a level, and have a top-level object combining the spring arm and camera that can be passed in to functions on the camera manager (I want to animate between these, incorporating the spring arm into the animation as a camera boom).

On first blush, my Camera object could be an actor that I add to the scene directly and then use Child Actor components to add to other blueprints. The problem with that workflow is that the actor in Child Actor component is not directly viewable or editable, i.e. the user cannot actually see the camera in Blueprint editor, move it around and preview it’s viewpoint.

So I wanted to do this with a purely component based solution. Unfortunately, as far as I can tell, you can’t nest components in the Blueprint editor, you can only do so on an actor. I can add the subcomponents in construction but then they don’t show up in the hierarchy (IIRC). The best I’ve been able to do is have a component that finds the spring arm and camera within its children at startup but that workflow isn’t great as the user has to know how to construct these properly or they won’t work.

Is there some obvious solution here that I’m missing?

Components with a transform can be visually attached to other Components and they have “On Attached / On Detached” events;

Their properties end up displayed on owner Actor’s details panel, example:

Yeah, I know about that.

I’m afraid I wasn’t very clear. What I’d like to do is set up a component hierarchy independent from an Actor. Using your example above, this would look like blueprinting the static mesh component and the the CLR components underneath it as a single object that I could then add to other actors and/or a level rather than having to create this hierarchy each time.

I have a relationship like this: CameraRootComponent->SpringArmComponent->CameraComponent. The CameraRootParent needs both children components to function. If I group this up as an actor the only way I can add this to another actor is using an ActorChildComponent which comes with a whole host of problems/limitations or to recreate the hierarchy each time by hand (doable but far less than ideal). I am looking for a way (in code) to set up the CameraRootComponent so that it always has its two subcomponents AND those are editable within the Blueprint/Level that they are placed.

From host Component constructor they can be added to Owner() Actor, but then they will be “inherited” and not editable.