Is there a way to create a reusable component that has a viewport and can be attached to any actor?

I want to make a component that has a Viewport so I can place various elements in it (UI elements that will be on top of enemies in my game).

As I don’t want to have to add those UI elements to all my actor classes, I would like to make a component that can contain all those things neatly packaged and be simply added to any actor I want.

Problem is:

  • There is the SceneComponent class which _does _ have a transform, but it doesn’t have a viewport, meaning it’s not very usable as I would need to place/instantiate everything in code/blueprints. I want to place things visually in the viewport
  • I could use the ChildActorComponent, but it requires casting, and I don’t really like the idea of having to make my UI an actual actor

Is there any other component class I could use that can be attached to an actor’s transform and has a viewport where I can edit its content?

More detailed explanation of the problem

For clarity, by Viewport I mean the Viewport that you would have in an Actor, where you can place elements inside that specific actor. This window is only available when editing an actor, not when editing a scene component, so it’s impossible to create a scene component that has a visual editor to place things inside.

Here are some screenshots to illustrate what I mean:

This is my main unit blueprint. As you can see it contains a “UnitUI” child actor, which contains all the UI features for units. I could only make it as a child actor, because a SceneComponent doesn’t have a viewport to place elements.

This is the content of my UnitUI actor:

In this example it only has one element inside, but eventually there will be multiple different UI elements all placed in the viewport. I don’t want to have to add those elements manually to all my unit blueprints, so I made this UnitUI actor to contain and control all of them, while the main Unit actor will only code simple functions from the UnitUI actor.

Scene components don’t have any viewport, here’s a screenshot from a scene component, with no viewport option:


This means that using a scene component, I would be unable to place my UI elements visually in the viewport, and they would have to be instantiated/placed in code, which isn’t a good workflow.

1 Like

what do you mean when you say has a viewport? the viewport is just a window where the game is displayed and is usually set to render things from a cameras perspective. ui elements are usually made with widgets. widgets can be either added to the viewport or onto actors. if your just looking to add something like a healthbar to the enemies and want them to appear say over their heads then go into the enemey character bp and in the components section search for widget.

I mean the viewport that allows you to edit an actor. A scene component has a transform and can have children, so it would make sense for it to have its own viewport where you can actually place those things.

The reason I don’t want to just use a single widget component is that here I’m talking of having a component that would manage multiple widget elements. I don’t want to add all those widget elements to all my units, I want to have a single component that contains all those things in one place.

Thing is, it’s not possible to do that in a scene component, because it doesn’t have a viewport to place other elements inside, so the only way I’ve found to do that at the moment is to add a child actor.

I edited my post with screenshots of what I mean.

so your looking to have one item that you can add to your units that contains certain widgets. you can do that with a widget. just create a widget and go to the components section on the left and you will see a section for user created or something similar if you have made other widgets. now you can add other widgets to the blank one. so lets say you had a health bar and a name plate as separate widgets. you can combine them within a third widget. i use this method to create modular ui elements.

child actor would also work id imagine.

Well this would work in this specific widget case, but my question is more about generally trying to find a way to have components that can be added to actors and that have their own viewport, which only seems doable with a child actor currently.

without having a specific example of what your trying to achieve i can only speak in generalities. that said i cant see a reason why you would be so stuck on this viewport point. using a canvas in the widget editor does the exact same thing. and if its not on the specific actor then its obviously not a character specific reason. so it doesnt make sense to me

that was the whole question!

Well, in my case, I need a series of editable “Billboards” that can be attached to my character BP as an optional component. These billboards can be edited on scene by designers and also they can add as much as they want to the character in BP editor. It was handy if I have a BP component (or similar) that has a viewport to add items and also assign some code to address them, like what actor components do ai character guard points.

I tried to use AI controller viewport to add visual components, but sounds like it doesnt “show or render” anything.

I think that only solution is to create actor blueprint and than spawn and attach this actor to other actors in game.
And do not use “add child actor component”! It can’t be deleted even if you use node “destroy actor”“destroy component”, actor is stil in game.

So, spawn bp_actor. Attach pb_actor to actor. Destroy pb_actor.
Maybe there is another solution, i don’t know.


Is there any progress on this?
The whole point of having a Component Editor with Viewport is to make Components more reusable just like Actors.

Right now, it’s impossible to create nested Components without having the Component added to an Actor first and then add more Components to the parent Component from the Actor Editor only.

It’s because the Component Editor doesn’t have Viewport and it won’t allow adding stuff to the Component, thus creating reusable Component impossible.

1 Like

I have another example of when this would be useful.

I’m trying to make a game where all sorts of objects are ‘selectable’ by the player. Selecting the actor would draw a box around it.

I would like to make a “SelectionTarget” component with the logic and box mesh that I can add to any actor.

It wouldn’t make sense to do this with inheritance, because some of the selectable things are Characters, and some are plain Actors. Put another way, the concept of a ‘selectable’ thing doesn’t fit nicely into the hierarchy of classes.