Child Actors on Actor Portrait


Introduction

I was recently contacted by a user of my Actor Portrait plugin asking if it was possible to display multiple actors in the actor portrait, and the answer is definitely yes! What you have to remember is that the actor portrait is a fully fledged UWorld, just like the one you use to support your game. You therefore have access to all the same tools as you would in your own game, you just need to know how to utilize them!

Child Actor Component

The first way of adding child actors to your portrait is through… well ChildActorComponents.

You can add a child actor component to the actor you wish to display in the actor portrait like so:

You can then access this child actor component through the ActorPortrait Widget like this:

The advantages if this technique is that the lifetime of the actor will be handled for you. You are also able to do any posing of the actor (such as attachment to any sockets, or simple placement) through the unreal actor editor UI.

The downsides is of course the limited ability to generate more complicated actor-structures at runtime. If that is what you need you might be interested in the next chapter where we go over spawning the actors in the actor portrait scene yourself.

Spawning Actors in the Actor Portrait Scene

If your requirements for spawning actors in the portrait scene are more complicated, or you just need a greater level of control over the actors which are spawned in your scene, then this might be the chapter for you.

Remember how I said the actor portrait scene is a UWorld, just like the one supporting your game? Well, that means the SpawnActor node works just as well in there! The only thing you need to keep in mind is the context of which you use this node. You can only spawn actors in the portrait scene from within your portrait scene.

You are now also responsible for managing the lifetime of these actors. Once the UI element holding the Actor Portrait is closed, all the actors within its world will be destroyed with it. However, during the lifetime of the UI element, only the actor spawned through the Actor Class property on the portrait widget will be managed for you. Any actors you spawn by yourself is up to you to keep track of.

With all of that out of the way, let’s spawn some actors in our portrait scene! I am using the BP_PortraitExampleActor and the UMG_EquipmentInspector from my example project.

Inside my BP_PortraitExampleActor (remember, the actors have to be spawned from within the portrait scene) I add a function which generates my desired actors.

I can the call this function from my UMG_EquipmentInspector as follows:

Showing the UI in game we can how see our spear actor next to our actor: