Problem with my progress bar

Hello, I am using a UMG widget to track my health aka shield.

Here I have a User Interface Widget Blueprint. As you can see I bind the percent to my Health variable.

In this Graph of the widget casting to where my variable is.

My variable Health getting the percent of my max health from 1 to 0.

I created the widget in the level blueprint.

In this video you can see that the bar is empty all the time, I’m printing my health variable on tick as you can see on the left.

Can someone tell me what I missed.

Where is the “print string”? In character BP or UMG?

If we do it in UMG we can check the real value that is receiving.

Anyway, Could be your problem that you have unchecked “is variable” in your “Shield Bar”?

put it in the char bp then just print the value out.

I had it on my character BP, I moved it to the HUD and it prints out 0, when I exit I get an Error Accessed None ‘K2Node_DynamicCast_AsFlying_Pawn’ from node Cast To FlyingPawn in blueprint my_HUD. I checked is variable and it is till not working.

The Accessed None Error could come from a few ticks that the Bind tries to use the variable before the OnConstruct actually fills it.
I normally bind a function instead of a variable and then you can use a “IsValid” node for the Pointer/Reference Variable to make
sure that you don’t use it when it is NULL/empty.

Is the Health Variable also 0 in your CharacterBlueprint? Because if yes, then you have some false calculation going on there.
If not, then you might want to bind a function instead of the variable.

Well that explain where is the problem.

If in Character BP value is correct, but in HUD isn’t, then the problem is that it isn’t getting the value correctly.

I guess I found the problem exactly. It is in your second image (and other things, but step by step). I guess your “My Character” isn’t a “pawn” type and your “get player character” I replaced it with a “get player pawn” (well, atleast should be a pawn right? if not, you can’t move it)

With this code I am making a reference to the pawn controlled by Player index 0 when widget is created.

This other code is where I checked the value of the “binding” of a text in the widget. It update the text correctly with the “pepe” variable value in my characterBP.

I hope this help you :slight_smile:

Edit: eXI posted while I was writing :P. Thanks for explain that error! Btw, look like the OP have the correct values in CharacterBPs, atleast it is was look in the video.

Edit2: I guess I learned somethings with this thread ^^. Ill practice the references again. If I said something that make you move your hand to your forehead and move your head side to side, please forgive me. Ill work harder to learn more.

So the problem could be only that he is trying use a variable that still doesn’t exist? That could explain why my code worked, because I did a fuction instead a variable reference for the bind (I must admit that I don’t know how to bind a variable directly there :P).

Thanks again.

@vegetamaker: You also need to fix something. The “NOTE” displays it. In a function, each possible exec needs to end in the Return Node.
In C++ this will give compile errors if not! That’s why Epic made multiple return nodes in 4.9.

To get this working i do the following:

Create a LocalVariable for the Function. Make it the same Type as the ReturnValue (text here). Now, use 2 Set Nodes for this variable.
One Set node is for the working part, where you just plug in your “pepe” value. The other one is kept empty and all failing execs will
go into it. Like the CastFailed.

This fill fix the Warning and should always be used!

That NOTE mean! I thought all this time that I pressed a key when I not should and added a note (promise, I spend some time looking what was that :3).

Thanks so much eXI!

Let me ask you something, what is the node that is linked to your “Character Ref”? I guess I will need it soon :3

A self made Struct. Structs are good to save a bunch of variables and keep them together.
You can create your own.

But let’s not further spam his thread here with other topics. If you need help with structs etc,
feel free to open your own thread.

@OP: The Screenshot i posted in my other post above is how you want to make your Bind Function.
But you will take the Health variable and not a Struct like i did. Then you select this function for the
percentage bind.

Very nice explanations. I love it when I learn new things.

Thank you so much, I fixed it. vegetamaker was right all I needed to do was change it to get player pawn. It’s working perfect.