Hi, I’m trying to visualise my actors in a list in my UI.
So the way it goes is I’m spawning actors in the world and I want those actors to automatically populate a list just like the world outliner does in editor.
I need to then be able to select the item in the list and it will correspond to the actor in the world and highlight it.
I have the highlight part down. I just don’t know what this system is called to be able to find out how to put it together.
I’m thinking of something like:
Actor spawns and adds a child widget to my UI widget in a scroll box
The child widget is a button or some kind that lets me click it to fire events
Once item is clicked, the corresponding actor in the world is highlighted
Then also the associated information about the actor is displayed in a text box like a description and user editable text fields.
I have a save system that should be able to save all of this data once changes are made.
from that description i don’t know of a “system” that does that.
it would actually help to know what your game/app is trying to achieve. to get a better idea.
maybe you can check “factories”, but that’s a pattern not a system. (and i usually don’t like factories much).
though from your description it seems you look for a pattern more than a system.
also check “subsystems”.
you can have a base class for your actors, and when they get spawned they get a ref to the subsystem and “auto register” and when they get destroyed they unregister.
that’s pretty nice because sometimes you might want to de/register while it’s still alive.
maybe because you use a pool, or maybe because you use de/activate. (like hiding and stuff).
the subystem can (and i’d recommend) have delegates for OnAdd and OnRemove of these actors.
the ui binds to those delegates and adds/removes ui widgets accordingly.
those ui widgets can be a widget blueprint for each item.
i’d recommend have a widget that’s not a button, but has a button. so you can extend later on.
It sounds more like I need to check into subsystems.
Basically what I’m doing in my game is very software based. So in my UI I have a list to my right and this list needs to automatically populate with the actors I spawn at runtime. These objects hold data like descriptions and things.
It’s more like analytics and each actor I spawn represents a measurement/ highlight of the location of interest. These actors spawn a form which I fill out with a description which is saved to the actor.
What I need is for this actor to be represented in the list I’ve made, so I can select the actor in the list and view its details and edit them if needed.
I think also UGameInstanceSubsystem with an ActorComponent.
Subsystem and actor components talk and do registeration, unregistration.
UMG talks with subsystem and updates lists with events and actor references.
When item is clicked Actors Component is retrieved which holds data, and in umg is displayed. Visual feedback happens like overlay material to component owners static mesh if any. Better to send clicked function over subsystem to actor so UMG becomes independent fully from system itself.
When data edited Actors Component data is written.
Actors component save its own data as SaveGame object on event or endplay, retrieved in begin play if exists, if not displays default.
certainly. even if you then decide you don’t want them. they are very very powerful, efficient, and integral to ue. so do check them out at least to know how they work and what they can provide to you.
I looked into them and learned they’re c++ only and I don’t have time to convert my project and study this to implement. Deadline is wednesday.
Instead I discovered the listview item in the widget and learned that I can dynamically add items to it.
The only problem I’m having now is how to add my spawned actor as the item reference in the list view. I’ve got such a headache and every way I’m trying is super convoluted it’s embarrassing lol
I thought of that but I came to the same issue. How do I tell the asset manager (the BP in my level) to include and store a newly spawned actor?
Is there some kind of ‘get last’ function I can do or something else?
I don’t know why but I think I’ve been able to do it before, and suddenly I’ve just got this mental block.
All I need is to be able to store the actor I spawn dynamically at will. Imagine it like a fort builder. I spawn an actor which holds data about itself. Then this actor needs to be stored in an asset manager, and the list view accesses this to display in order, each of the actors the asset manager holds.
When I click the actor in the list view, I can then use the widget of the list view to trigger some events like deleting the actor of choice.
there is a delegate on the engine for when an actor is loaded i think, but i can’t recall if you can use that from bp, i’m almost certain you can’t and i don’t remember the name atm.
just make a base class, and on begin play you do this
add a timer for next frame (because this is begin play the manager might not have gone through begin play)
on next frame you GetAllActorsOfClass(MyManagerClass).get(0).MyFunctionToAddAnActor(self)
then the manager has a function “MyFunction…” that its public, and takes the actor.
stores it wherever it wants (make it transient please)
and has a delegate OnActorAdded and calls Broadcast or i think it’s Exec on bps. and pass the actor as parameter. you need to create your own delegate for this in the manager.
on your ui on OnInitialize (NOT on construct), you again put a timer for next frame, and getallactorsofclass(Manager). then bind to the OnActorAdded and do your stuff.
I really appreciate you trying to help but I’m sorry the above quotes there seem to be c++ based or when Auran13 said “add actor” I can’t find any nodes for adding actors to anything other than ‘layer’ even with context sensitive unchecked.
I’m trying so hard to understand what you’re saying but I think I’m missing a few important pieces of knowledge that would tie all of this together.
thats why i said pseudo code, you have to make that function yourself, which also means you need to cast to your own GameState. or any other suggestion above.
just break down the steps like i did and work your way through
I am 80% confident in what I think you’re asking me to do in the pseudo code but I can’t do anything on begin play because it all needs to by dynamic.
The items I spawn in the world need to be added to the list and hold reference data on the fly, let me delete actors from the list which deletes the actor in the world and other functions I need.
This is the part I get stuck on. I’ve added actors to a list from begin-play, but that apparently only worked with blueprint objects specifically, not the actor itself and any reference I create there such as an actor variable has no effect. It doesn’t know which actor in the world it is and hold no association.
I’m just going through the tutorial to understand further, but maybe I’m looking at this whole thing the wrong way because the way I’m picturing it is:
spawn actor in world
this specific actor is referenced directly in the list UI
I can click the actors in the list and whichever one I click corresponds to the one in the world.
And I don’t think I want to keep using get all actors of class everytime I spawn one of these actors, because I’m going to be spawning quite a lot.
You want it to be dynamic
You want only blueprints seems to be since we cannot conver project and deadline issues.
You want it to be stored.
So that things become on the fly basically.
I just made a prototype to be sure that it is working.
What I do,
On player begin play.
I have a list of text defines actors and its variables like, isSelected, name,description etc.
I access file and literally parse string manually so I have arrays of data of what needs to be spawned, write into BaseActors.
I keep changing things, selecting actors and it always writes into actors.
Before end play I parse back items and write into file.
As said there is many ways to do it however when it comes to Blueprint only its kind of a hard subject to nail down nicely.
You can basically use unreal data tables however they are read only, with C++ you can make it a bit Read/Write however by default no.
So the solution basically comes to
Data driven design which I like. You can use various solutions for it.
You can make a save game object use. You populate some actors on screen. They retrieve their data on begin play and save themselves end play. UMG only talks with actors, get all actors of a class can only run once to make arrays then its just array operation. When an actor spawns they can already save themselves into savegame object, if deleted they don’t. So basically you can always have a persisten data with it.
You can use a SQL plugin to solve your data saves with ease what I think is an overkill.
You can use an excel plugin which will resolve your problems as fast as possible since deadline is close.
Thanks Grimnir this is helping clear things up for me. I think I’m about 60-70% of the way there, I’m just now trying to work out how to get my stored actors to populate the listview lol once this is done.
I can then start adding all the steps required for the end-user to fill out the data of the asset they want which can be saved to an excel sheet.
CSV I’m thinking (or is it CVS?) anyway once I figure out how to directly reference actors from my listview to delete/ rename etc.. I’ll move onto the data part.
I really appreciate all the help here from everyone, I’m completely new to data driven programming so a lot of this are still quite complicated for me.
That’s exactly it I think, I have a game state I made and I’m using a map to store all my items which currently is successfully being populated with a unique ID and the actor name (though it’s a duplicate, it just adds _C01 to the end)
So this manager is in the game state, I’ll use your advice to fire the events to update the listview in the UI, thank you
Hey Auran13 Just wanted to update you and everyone else here @nande@RedGrimnir I managed to solve this without it being too convoluted.
Here’s what I did:
I created a game state which I will store a component I’ve named ‘ActorManager’.
In this component I register, unregister and ‘getRegisteredActor’ in seperate functions. What these basically do is add to a MAP which contains a name and an actor reference.
In my spawning actor I add another component I made called ‘register actor’ which has a custom event that references the actor manager in game state, gets the owner of this component and the unique ID I set in the spawning actor and sends it to ‘Register Actor’ in the AssetManager component.
It also unregisters if the spawning actor is destroyed.
From within the ActorManager upon registering I get my UI widget with ‘get all widgets of class’ and fire an event through its reference return. This event has an input for the unique ID which I link from this component through to my widget.
There in the widget I ‘getRegisteredActor’ from the game state > ActorManager component and then feed the info into the listview directly: