Communicate from UMG Button to Blueprint Actor

Im struggling in establishing a communication between a UMG button to any other blueprint actor. Normally direct communication between blueprints is relatively simple, by using public variables that could be “filled” with actors in the details panel of the editor.
But since a umg widget is not existing in the level in the editor yet, because it will be spawned on begin play, I don’t know how to connect actors blueprints to umg buttons.
I would like to to quite basic things like setting the rotation of an actor by clicking on umg buttons, or the position, or the visibility, or the material for exsample.

Dose anybody happen to have any idea?

Have you tried the ‘GetAllActorsOfClass’ node?

Thank you so much, this was the solution :slight_smile: I have heard somewhere that this might consume some performance, is this right?

Yes, when you try to iterate through a few thousands of actors of this class, to find one specific…
If you try to get an actor out of… say 100… it´s not really dropping any performance.

The second, and most simple way, is to create a new Variable in your UMG Widget, As Type, set the Actor Blueprint… and activate “Expose On Spawn” and editable…
This will allow you to fill this Variable on CreateWidget.

Don’t use *GetAllActorsOfClass *node for something like this - it’s meant for something else and this just leads to bad practices. What if you have 3 actors - how would you know which of the 3 the node fetches is the one you want… ? It does not even guarantee element order :expressionless:

How actors communicate will depend on what you expect to happen and how you set things up. Actors in the level blueprint vs actors spawned run-time, for example. One widget per actor, or one widget for many actors, many widgets that manipulate 1 actor, perhaps? Are you going to work with inheritance a lot? Do you need *unrelated *classes to talk to one another?

Just posted this, see if it answers your question:…ed-distan.html

This is a self-contained method but dispatchers can be hooked up to anything. More here.

Edit: check here, too

Thanks a lot. That “Expose on Span” seems to be a easy solution.

I had initially tried it with event dispatches but have not fully understood how to set them up because they needed some references, Im not awarenesses of how to obtain. (e.g. the other acton as target in the call node)

Well, it definitely has some overhead, even if it is completely negligible in this particular case, and as others have mentioned it isn’t the best practice to find specific actors using this method. A cleaner solution would be to store your Actor reference in a class that has its lifetime managed by the engine (PlayerController, GameMode, GameState, etc) as you can easily grab a reference to those.