Branch node doesn't return correct value

So I’m doing my first Match game and the logic I use to define what to spawn when matching two actors is taking a Float Variable from each actor and adding them together. This works as intended for every match except the first one (2.3) and even though I’m debugging with Print String to verify that I get the result 2.3 it will still just return everything False (and thus not spawning anything)

Can anyone think of something I’m doing wrong?
I tried simply switching the True and False Execs but that just makes EVERYTHING to turn into the object intended for 2.3 :stuck_out_tongue:
I also tried putting the first Branch node in the “bottom of the stack” but that just returned the same problem.

1 Like

I want the Branch node to accept that in this case (1.1 + 1.2) == 2.3
It’s not too much to ask for considering that the other Branch nodes accepts that (1.1 + 1.3) == 2.4 and (1.2 + 1.3) == 2.5

I do not understand What do you want to do?

spawn diferent ators when you put the diferents values in the float ?

ok i make a video for you wait a moment pls what version of unreal you use ?

4.12
I’ll make a video when I come home, but what happens is that the Branch node doesn’t accept the value == 2.3 even though I’ve used print string to debug and verify that the value is in fact 2.3.
2.4 and 2.5 returns just fine.

if you’re right no show me the 2.3 if you use the == but you can use the >=
the == have a problem with that number.

Thanks for testing it rjvm but my issue remains. However I had an idea for re-working my system to what I think is a better solution so I’ll just close this issue.
It’s still a very weird problem though.

You are likely running into floating point round off errors. They don’t happen as often when simply adding two float’s, but can still happen sometimes.

When you perform math operations on multiple float values you will sometimes get a value that is almost, but not exactly the value you want.

In this case 1.2 + 2.1 could potentially return 2.300001 (example only). The reason for this is float’s only have about 6 decimal places worth of precision before they start running into round off errors. The precision is good enough for most uses in a game engine, but using them in a math equation will not always produce the exact value you are looking for.

For that reason you should try to avoid using the “float == float” node, there is no way to guarantee it will be equal. You should use less/greater than or equals, or even two integers (one for the whole number, the other for the remainder) instead to ensure it’s accurate.

Hope that helps,

1 Like

Thanks! I had no idea about this :slight_smile: I’ll have to be more careful around computer math