Hi. I wrote script that moves object a = 110 times by b = 0.1f from x = -5.5f and i expected that this object will be in position x = 5.5 but insteed it is in position x = 5.499995. Why is that ? How to deal with it ? I dont want to extort specific values because a and b will be change during the game. Sorry for bad english and thanks !
I don’t know how to do what you are asking. But I’m imagining it would not be worth it. If you need to test whether the object is in position or not just test that it’s within a very small range. I mean you are talking about very very small discrepancies. I always see unity moving my objects very close to where I wanted and not the actual spot. I let it go…
Ok I found a solution. Using a Kahan summation algorithm i can reduce error very strong. If I would move object milion times, error would be greater and impossible to miss. This alghoritm unfortunately is not perfect and goes 4 times longer but in my case I move object with relatively long time intervals so i can calmly use it