Hello guys, this is my first post here, i hope you can help me
I have a simple question. I have a widget called BPI_W_CONTADOR TOTAL and, inside of it, i have a float variable called “Precio Final Total” which its value changes during the game (it is a price). That value is set in the respective widget and everything works fine when i want to see it in the screen directly from that widget (adding it to the viewport).
320333- The problem comes when i want to take that variable from my Level Blueprint and do something with it (what i want to do with it is not the key of the question) because, when i take that variable, it seems like its not updated. The value that it shows me is 0.0 instead of the new values that have been set when i play
I tried different approaches to call that variable in my level blueprint, like creating references of the widget in my BP_CHARACTER that, later, is calling using a “cast to”, a “get all actors of class”, or even directly creating my widget and calling that variable.
I believe the event construct of a widget fires upon being added to the viewport. Are you perhaps trying to get the value of this variable before the widget has ever been put on the viewport?
I replicated what you tried to do, and for me it works perfectly.
Given what you show, you try to get the variable on creation of your widget. This will always give you the default value (which is by default 0,0) since it is constructed at that time.
You also try to get the variable through your BP_Character, the problem will probably lie there.
Example of how I replicated what you tried to achieve:
I created a widget, with a variable MyWidgetFloat, and added delta time to it on event tick.
In my level blueprint on begin play I create the widget and add it to my viewport.
I get the variable in 2 possible ways.
1: by using a variable I set on creation of my widget, and getting the variable from there.
2: by using get all widgets of class, getting the first one (since there’s only one) and getting the value.
In my level blueprint, i created a reference of the widget and i took the variable from it, but instead of returning me a value of 12 (2+10) it still gives me 2…i dont understand!