4.21.2 healthbar issues

So I feel quite dumb for asking this, but I am at a loss. I know about 3-5 different ways to make a healthbar, but I just seem to not get it done today. I watched 5 different tutorials each with a different methode and engine version. I tried all and none work. The problem: Health seems to work when I print it to string, but my GUI bars remain empty. Everything seems to work except for the code that should change the bars appearance based on health.

What I tried so far:

1: Use value of current health directly.

2: Use values of 100 instead of 1.

Here are some screenshots:

267415-empty-hp-bar.png

How it shows up when I play

Player BP

Healthbar options

Code of the Bind function

267419-what-it-should-look-like.png

What it should look like

after a quick look at this i can tell two things:

first in your armor binding your division is backwards. it should be armor / max armor which will give you a 0-1 value.

the second thing is i dont agree with the way you implement decrementing your variables, its bad practice to have nodes loop back on themselves like that. it wouldnt surprise me if you ended up getting weird bugs due to scripting like that. but this is just my opinion and you can do as you like.

Well I redid my bad way of updating my health and used GetHealth this time. Thx for pointing that out :wink: It has been a while since I used the engine and forgot my proper ways ^^. I flipped the max armor/ armor division, but it made no difference. (not visually at least).

The third person character is my playable pawn, yes. No other characters or anything else with health variables is present yet. I think that is what you mean?

You probably are setting player health or max health to 0 somewhere and since it is a binding this automatically updates and you don’t even notice it was ever at 100%. Check all references to you health variables, see where you are using them and make sure there isn’t anything overriding the initial “event begin play” setting of the values.

So I used a print string to check my hp value on the tick with 0.2 second intervals, and it was at 100 all the time without making changes to it. So I know the value is correct. It is the UI that is not displaying the right value from some reason.

EDIT
I gave the binding a direct value of 1 into the return node. The bar remained empty. So I do think it is getting a correct value, but it doesn;t display it. When I tried to remove the bind and give it a value of 0,5 it displayed a half full bar as it should. so the problem is in the binding, not the bar or the value. Possibly something I need to write in the event graph of the UI?

your character does inherit from the third person right?

Try deleting the progress bar and its binding and making it again. Sometimes you just get silly bugs in BP

@Nebula Games Inc

Turns out you were right. My code was fine. It just bugged out. I completley removed my UI widget and remade it in the exact same way and TADAA. It worked. I want to thank you. I am now going to feel sad for myself not try this is in the first place xD

Haha, I have suggested this to a number of people as a solution when things just don’t seem logical at all. If something as simple as basically displaying a value isn’t working how it should “restart” usually is the answer. Sadly I learned this after wasting countless days on silly bugs. I think I tried troubleshooting a problem for about a week no joke only to get so frustrated I started over from scratch and next thing you know, problem solved. That is how I stumbled upon this simple but effective solution to weird bugs. Blueprints for all their glory suffer from phantom bugs, sometimes nodes just break, widgets don’t work…I currently have a bug with “Quit Game” that won’t work in editor but is just fine in a packaged build. Not complaining about that better than the reverse :slight_smile: So don’t sweat it, just spread the knowledge and save countless man hours!