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"

Progress bar percentage is not correctly representing actual values

So I am making a First person shooter. In this fps I have made some basic enemies that have a health bar on top. The actual function (health decrease and death) are working fine. And the health bar was working correctly too. I set up the enemies so that they die in 2 hits (a total of 1 health, with 0.5 damage in each shot) and the health bar widget worked fine. What i cant get to work however is to reflect the health loss in a progress bar correctly when i increase the hits that are required to defeat the enemy. I am not increasing the total health, i am simply decreasing the damage per shot (from 0.5 to 0.25) In the first video i show the health bar widget working correctly when i am dealing 0.5 damage in each shot, killing the enemy in 2 hits. In the second video i show the health bar widget working incorrectly when i deal 0.25 damage in each shot (you can also see the health remaining after each shot on the top left corner)


https://www.youtube.com/watch?v=kzCbrj8vOI8 In this screenshot is the variables that i use to change the damage per shot and the total enemy health. alt text

Here is the bind in the widget blueprint, I suspect this is where i mess up,however i am not sure what is my mistake alt text And here in the enemy blueprint is the system that I use to decrease the health after each shot alt text

Any help would be much appreciated

Product Version: UE 4.18
healthbar-sc1.jpg (236.1 kB)
healthbar-sc2.jpg (433.2 kB)
healthbar-sc3.jpg (444.9 kB)
more ▼

asked Feb 15 '18 at 10:53 PM in Blueprint Scripting

avatar image

9 5 5 10

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

2 answers: sort voted first

OOOK sooo i found my mistake.

Turns out i didnt scale the health bar to 100% so i could see the first hit effect the health bar...

....sometimes i question my sanity :P

Thank you to ThompsonN13 though for taking the time to help me!

more ▼

answered Feb 17 '18 at 07:14 PM

avatar image

9 5 5 10

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

ok well first things first you dont need that cast node that you have in the widget (in the current implementation). also the way you are getting the health is a poor way to accomplish it since you are getting all actors of a class( this could cause issues).

why are you not using the built in damage systems? there are nodes for apply damage and event any damage. if you were to use those you could create a much more dynamic scenario.

to start try cleaning up the widget and see if that helps. if not we can work from there. or you could just set the value of the health bar manually as pictured below. make a variable on the health bar and bind that to the progress bar percentage. then whenever damage is applied just update the variable.

alt text

capture.png (172.1 kB)
more ▼

answered Feb 16 '18 at 12:25 AM

avatar image

10.1k 33 10 25

avatar image Pravok Feb 16 '18 at 03:53 AM

I didnt even know that these nodes existed, thanks for telling me! I looked up some tutorials and most seem to use line trace to work with these nodes, however i use a projectile. So i assume that what i would have to do is to apply damage on event hit of the projectile and cast to the actors that i want for the apply damage node.so my problem now is what do i plug in, in the object thingy when casting(i feel like the answer is going to be simple but i cant seem to find it on my own)

alt text

This is in the projectile blueprint on the event hit.

sc1.jpg (325.0 kB)
avatar image ThompsonN13 Feb 16 '18 at 04:25 PM

When using the apply damage node you dont beed the cast node. If you look on you hit event node there should be a blue pin that says other actor. Just drag off that pin and plug it into the damaged actor. This way anything you shoot than can take damage will. I would post a picture but im on my phone right now

avatar image Pravok Feb 16 '18 at 08:00 PM

That makes sense. Ok so i got it to work with the apply damage and any damage but i am still not sure how to fix the health bar issue i mentioned above. (i didnt change anything in the widget yet, not sure what to change)

(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