Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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:

alt text

How it shows up when I play

alt text

Player BP

alt text

Healthbar options

alt text

Code of the Bind function

alt text

What it should look like

Product Version: UE 4.21
more ▼

asked Feb 03 '19 at 03:54 PM in Blueprint Scripting

avatar image

94 5 8 12

avatar image ThompsonN13 Feb 03 '19 at 04:09 PM

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.

avatar image ApocalypticAI Feb 03 '19 at 04:18 PM

Well I redid my bad way of updating my health and used GetHealth this time. Thx for pointing that out ;) 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).

alt text

newandimproved.png (63.7 kB)
avatar image Nebula Games Inc Feb 03 '19 at 04:37 PM

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.

avatar image ApocalypticAI Feb 03 '19 at 04:44 PM

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?

avatar image ThompsonN13 Feb 03 '19 at 05:20 PM

your character does inherit from the third person right?

avatar image ApocalypticAI Feb 03 '19 at 06:17 PM

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?

avatar image Nebula Games Inc Feb 03 '19 at 06:44 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

@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

more ▼

answered Feb 03 '19 at 07:45 PM

avatar image

94 5 8 12

avatar image Nebula Games Inc Feb 03 '19 at 08:18 PM

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 :) So don't sweat it, just spread the knowledge and save countless man hours!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question