Hi! I know my version is a little old, I have been working on it on it on and off over the past year or 2 whenever I have free time.
I really need help accessing a variable from a widget blueprint, within an actor blueprint. I have read other somewhat similar articles but I just cant seem to grasp the responses, sorry maybe I’m just dense…
In my widget Blueprint I have a simple Boolean variable that is set true or false with a button and a flipflop:
In an actor blueprint with a simple cube mesh, I have an “Event Actor Clicked” connected to a branch, and its condition is the boolean from the Widget BP that I flip on and off.
What would be the best way to get that variable? I cant seem to figure it out.
Like this? Sorry Im not sure what you mean. by “Get(Copy) from found widgets”
Set a reference to my Hud where? In my Actor? I don’t know what you mean by “get the button from that”,?
Nevermind! I figured out what you ment. This is what got it to work!
Thank you for your responses but I figured it out!
Get All Widgets of Class function is one way to do it. Show your widget as widget class and then Get(Copy) from found widgets, finally get/set any variable you like. Or you can(actually you should) get a reference of that widget in the BP you are creating it in, then set/get whatever variable you like through there.
you can set a reference to you hud and then get the button from that and get the variable that way
so getting the button didnt let me do anything but i could get the bool and anything else in the hud
Sorry, forgot you were on 4.14. Newer versions have two types of "Get"s.
Also, even though this system works the best practice is getting a reference of the widget when you create it as i and dabs863 suggested. What you need to do is this:
Lets say you are creating the widget in your Player controller. When you create the widget pull the blue out pin and promote it to a variable. That will be the reference you’ll use whenever you need to get/set a variable from that widget. This is especially better than get all widgets of class when there are multiple instances of the same widget but you dont know which is which.