Compare Float with <= 0 Branch

Hi, I was doing some simple tests with float and I didn’t get the result I wanted to. I had a health variable and each time I pressed E I wanted to reduce some health until I got to 0.0 or under. It worked if I used 0.25 and 0.1 and 0.5 and so on but it didn’t work with 0.2.

I found the node “Nearly Equal (float)” and it worked with that.

You can see here that it first goes to 0.0 and then in goes to death.

Best Regards
AirBlaze

1 Like

Hi AirBlaze,

This is a known issue. What you are seeing is a Float Point Error and it’s just a quirk of the engine. The NearlyEqual node you are using was implemented into earlier versions of the engine to accommodate this issue.

Cheers,

TJ