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.
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 And here in the enemy blueprint is the system that I use to decrease the health after each shot
Any help would be much appreciated
asked Feb 15 '18 at 10:53 PM in Blueprint Scripting
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!
answered Feb 17 '18 at 07:14 PM
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.
answered Feb 16 '18 at 12:25 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here