Why does <= only work as if it was <?

I have a code which applies damage on pressing " / " key and a conditional loop set up to register when the current health variable reaches 0. The less than or equal too node only returns “true” when health current is less than 0. Why is this?

(Picture containing printscreen of blueprint set up).

Alright, I’ve solved it… In a way I really shouldn’t have had to do for a simple maths operator xD.

I changed the value in the less than or equal too node to 0.001.

That’s it.

Are you really sure that you get to the point where the health is 0? Or by pressing “/” you just get a point under 0?
Can you post a screen of your log where health reaches 0?

Float is a tricky thing. When it shows 0.0 it can actually be 0.000000000000000012.
Use Nearly Equal in pair with <=.

You can test by getting floor value before making comparison. Drag health Content node and find “floor” node and then use its output as input to your conditional statement. If it is the problem with float then it should work this way.
And “<=” node will be comparing two Int values now so make sure to change that too.

It might be kinda obvious at this point, but the node works fine:

And that ‘Nearly Equal’ node is a nice trick, although it seems the error’s value must be less than the tolerance, not equal to it.

Yeah, as Arida said, floats can be a bit tricky. I would advise using the method Ambhar suggested, so you are using the correct values.

Thanks guys, I didn’t realise a few people had responded. I think it is just the finicky float thing! Nearly Zero thing helps :slight_smile:

It’s so hard to find tutorials that pick up on little things like this :stuck_out_tongue: