In my third person character I set up logic for the player to receive damage and even death from the enemies. In the following the damage variable is set to 10.
However when I take the set out, the game starts with a full health bar, but after just a few punches from the enemy, the bar immediately goes empty and it does not increment to nothing.
Make a new divide node but of type float / float. In the bottom half put in 100 and hook up the top part to “Player01Health”. This should make it go from an integer to a float via a conversion node. Then get the result of the division (a float) and hook it up to the return node.
You bar is emptying at once because you’re not getting fractions but ints
You could also use the map ranged node
As your value put your current health
InRange A = 0
InRange B = max health
out Range A = 0
out Range B = 1
and plug the return value to your progress bar
But honestly I don’t understand why the integer did not work. If I’m subtracting 10 from 100 and not using decimal pointed numbers, then the health bar should have subtracted a tenth of the health bar everytime. Oh well, maybe the progress bar has to be a float for whatever reason? Thanks again.
Unreal doesn’t internally convert int to float so there is zero precision when it comes to the division.
It’s a hard lesson to learn and reflects more on programming fundamentals (differences between, int, int32, float, double etc). They all have their own properties and to do division you need precision (you lose the max limit a variable can hold but you get fractions in return)