How to get variables from randomly spawned actor?

On target point spawn random sphere (red or green). Spheres is blueprint with bunch of variables like name - color.
On left side we have colored buttons, player needs to choose what color of spawned object.

How can i can get variables of spawned object?

I set “Spawned Object” variable (as object reference) after SpawnActor, but i cant get access to that variable in the widget?

I solve the problem with getting variables. But i’m not sure it is correct appoach.
Forget level bp. :smiley:
So… I create bp_MasterObject with variables, and childs from him (Red and Green sphere). They spawns on the one Target Point randomly.
Another bp with “3d widget” inside get info from spawned objects correctly.
But i have one problem.
If i check storaged variable via “Print String” he print 2 variables
ONE from MasterObject default value (which on the level)
and SECOND from Spawned child object.

I think it’s not good. And i dont know how to make system work without Master Object on the level, because in that way I create a reference and “spawn logic” inside him.

your explanations are a bit hard to understand. how are you accomplishing the communication between the actors? from the sound of it you have a actor which contains the widget and a actor that is the sphere. the issue your running into from the sound of it is that there are actually two sphere actors and your getting the info from both. this leads me to believe that your method of referencing the sphere is flawed. show us your script so we can see how your doing things, this will be the most expedient method to solve your issue and make things clearer to us. also what is the context here, what is your end goal of this system? there may be another way to implement it that may be simpler.

Communication accomplish with casting.
End goal is create system like… Paper Please game.
Where we have Subject on the right side, and we must compile the correct data in the widget on the left side picking the right categories.

Parrent MasterScene bp - (Generate function)
Event graph almost empty except print string to check variable

Widget Logic (Generate, Destroy, and Check buttons)

ok i have never played that game so i looked it up. it looks like the player never moves in that game and you basically are shown a thing and if it doesnt meet the required spec then you press a certain button. so for your case your just looking for a sphere to show on screen then the player has to choose the right attribute, basically asking the question what color is the thing. that seems pretty simple and could be done entirely from the widget itself. its like a quiz game.

so heres what i came up with.

when the widget is created you spawn your actor (call spawnnewthing event). this event will spawn a master actor that contains a variable struct for all its attributes. i exposed the variable on spawn so the values can be set when the actor is being spawned, i did this so you could create a script to randomly assign attributes from a array. the spawn location here is set by another variable of type target point as in your example. this spawnlocation variable will be set when you create the widget, basically off the create widget node you get a reference to the widget and you can set variables from there. the last bit is to save a reference to the actorthing we spawned for use later.

now for the button functionality you get the current actorthing so you can get its attributes. you then compare that to a pre selected value, in the picture below im comparing a name string but you could use anythign really materials, mesh, integers, etc. so the equal and the branch will tell if they selected the right button. if true then they are right and you do somehting like add points to their score, if false they are wrong and you take a life or whatever. then we need a new actor for the next round so to speak so we destroy the currentThing and call the spawn new thing event which begins the cycle anew.

of course theres way more that can be done with this like dynamically setting test values and attributes.

Unfortunately, not quite so simple. :frowning:
The reason why i did childs from master bp is…i need to make pre-made “things”.
Imagine like i want the persons with exactly that name, age, race, height…etc. Many persons. And which person spawn in current moment it is generated randomly.
So i created master bp with general variables, and then i set manually specific value in every child from him. (In my simple example it is color)

In your example random stats sets when actor spawned.
Your solution elegant for random stats and done entirely in widget,
somehow can we do that with pre-made stuff? Or we should back to my system?
I thought that decision with the parent bp is the fastest since the parent like a sample and its easier to create content with it.

if you need to work from pre-made classes that a pretty simple thing to work in. for example in the below picture i created variable array and made its type the class of the master actor and its a class reference. this will allow you to store all the children in the array then you can get a random one of the child classes to spawn.

when i was creating the system i posted earlier i was making more modular so things could be procedural, just a design choice. also i try to eliminate unnecessary “moving parts” make things simple so you dont need things like the get all of class.

Alright, i got it. Thanks for such detailed answer! Sorry for my complex explanation, you helped me more than i asked in the beggining.

its very difficult to get variables from a level bp so a different approach would be better i think. where are you creating the widget? also what the long term goal of this system? it may be worth overhauling the entire system or at the least creating a spawner actor that you can reference.

if you are creating the widget in the level bp then you could just save a reference to it and the nset a variable in the widget for the info that you need.