As the subject line states the player does not die when health bar reaches zero. He will actually take an extra hit. Check out the Bp and if anyone finds anything please advise. Thanks!
Announcement
Collapse
No announcement yet.
Health bar reaches zero but player takes extra hit before death(SOLVED)
Collapse
X
-
I would suggest you to change the way you are comparing floats, see, a floating number can be tricky to compare as equal since it contains decimal digits. That means for example that 0.0 is not equal to 0.001. If you are only interested to check if the health has reached 0, you can compare if health is greater than 0, or lower than 0 (depending on the logic you are using), avoiding to compare two floats as equal. Also in this case when your actor takes damage, it will continue decreasing its health even when dead and therefore those mechanics for animation that you have will continue executing.
So for me, the aproach would be like this:
if (health >= 0): decrease the amount of health, execute animations, etc.
else: the thing you do when it dies.
That will prevent the actor to keep decreasing its health and executing animations after heatlh reached 0 or below, and also you are avoiding equal float comparison. Just keep in mind that whatever your actor does after death will continue executing when the event for damage is called, so I would suggest to include mechanics that avoid this, you can achieve it with a simple do once node, or by preventing the damage event being called using a few validations, there are many ways to do it, and you can implement it as fancy as you want.
For complementing: Unreal has a function that allows you to compare floats that are very near, and you can set how near you want the threshold to be considered both as equal, in that case you can force 0.0 to be equal to 0.001. However, I wouldn't consider necessary using such function to validate HP in this case.
Hope this helps.
Eduardo.Last edited by 3duardo1; 08-03-2019, 02:52 AM.
- 1 like
-
No that would not work at all. It is designed to go to the false area of the branch each time and it is subtracting health. A print string would go show up every time he took a hit. I did put one in after the branch and it printed when he took the final hit, However the Health bar was already at Zero. So I am wondering if the problem is the health widget itself?
Comment
-
The issue here is with your logic, since your branch only runs after something has taken damage that last time you subtract the value doesnt reevaluate the branch to see if youre dead.
Ive provided an image of how to fix your issue, cool.
Oh just noticed, when the player is dead you probably just want to do Set FullHealth = 0.0.Last edited by MonsOlympus; 08-04-2019, 02:21 PM.
Comment
-
MonsOlympus Thanks for that. I took a small section of your screenshot and made it work on my end. Thanks for everyone who commented and helped out with this!
- 2 likes
Comment
Comment