How to Communicate from Ui to actor BP

I’m trying to have a system where i click a “Build Location” then a ui menu pops up then you click the button of the object you want to spawn. I have it all setup but cannot get the spawning on the location working from the button. I tried “get all actors of class”/BuildLocation. That worked but it spawned the object on all build locations how can i have it only spawn on the selected location?.

Build Locations Placed

Build Locations BP

Spawn Object Ui


Spawn Object Ui BP

End Result

Okay, what you need to do is cast to the building you selected and spawn it from there. If you use get all classes your spawning it on every building of that class. How are you getting the UI to open up? One way would be to:

1:Set a variable on the widget which is of an actor type Building.
2: create the widget from the building(when you click on it.)
3: (On the building actor) Then all you have to do is take the created widget and set the actor type building variable to a refrence of self.
4 On the Widget just spawn the weapon of choice using the actor varaible.

You’ll also need to close the widget automatically if the player selects another build point. Perhaps create a visual cue for which one is seleceted.

Another way(Which may fix the above issue) is to use a raytrace on the mouse whenever left mouse button is clicked. Then if it hits a building it shows the widget or creates it. if it doesn’t it hides the widget. Then just do the above steps. ei refrence the actor send it to the widget.

Thanks that worked. I never though about using variables for it. :stuck_out_tongue: