Hey there, from what you show, it doesnt make any sense to me.
You have a Delay within the widgets tick event, where i assume it is never triggered since the delay (or Timer) will be reset every frame.
Then you have a “Character” and a “Energy(float)” variable which seem to be indepenedent from each other.
Then you show us a widget which creates an other widget when you click some button “Wrong Widget”.
You should provide us some more information with what should happen in your logic flow, by the way there are many tutorials out there showing how to create healthbar (or any kind of progress bar) where they show you how
to set up a communication between widgets and character stats
That delay on tick is a little scary… I wouldn’t recommend that. On top of that, you’re creating the widget and then a second later destroying it. I have no idea what’s going on in that last screenshot. You have some widget type variable that only has a reference to self that doesn’t do anything. And you’re setting it twice to nothing.
Well what shall he reduce when you give him a nullreference (-Energy) to get the actual Energy(float) value out of it?
You will need to get the right reference of the object containing such an energy value.
You should start at the blueprint where you call the node “Create Widget” get the reference of that widget and save it.
Provide a function in your widget blueprint (f.e. SetEnergy which has a float as input).
Then inside the blueprint where you created and saved the reference, take that reference and call SetEnergy.
The function now wants a float as input from you, so you will need to do something like this:
GetPlayerController (in case you arent inside a Playercontrollerblueprint)
GetPawn/Character ->Cast to CharacterClass which has the energy property
GetEnergy and take the output into your SetEnergy call.
Inside your widget you will have a variable of floattype “f.e. CurrentEnergyRatio”.
Inside your SetEnergy function take the input map the float between 0 and 1 and set CurrentEnergyRatio with that value.
Create a binding for your progressbar value.
This will create a Getter Function for you where you take your CurrentEnergyRatio value and drag it into the output of the Return node.