Comments and answers for "20 is not equal to 20 while using Vector3.MoveTowards"
http://answers.unity.com/questions/1384784/20-is-not-equal-to-20-while-using-vector3movetowar.html
The latest comments and answers for the question "20 is not equal to 20 while using Vector3.MoveTowards"Comment by Patrykgazing on Patrykgazing's comment
http://answers.unity.com/comments/1385925/view.html
@jobigoud That explains a lot. Thanks!Fri, 28 Jul 2017 14:15:40 GMTPatrykgazingAnswer by NorthStar79
http://answers.unity.com/answers/1385730/view.html
there is a function for this type of calculations: https://docs.unity3d.com/ScriptReference/Mathf.Approximately.htmlFri, 28 Jul 2017 05:52:13 GMTNorthStar79Comment by jobigoud
http://answers.unity.com/comments/1385654/view.html
This is the classical issue with floating point numbers. You should never compare floating point numbers resulting from computation for exact equality like that.
The proper way to handle this is to have an Epsilon constant corresponding to what you think is "close enough", and test for proximity.
Here is the obligatory link to "[What every programmer should know about floating point arithmetic][1]".
[1]: http://floating-point-gui.de/Fri, 28 Jul 2017 01:09:44 GMTjobigoudAnswer by megabrobro
http://answers.unity.com/answers/1384787/view.html
I had a similar problem and I took a lazy route of just measuring the time and changing it after the time expired.
I thought about a way to fix it properly and the way I came up with is setting a buffer float for the rotation and checking if the rotation.x < startPos.x + buffer && rotation.x > startPos - buffer.x
Bit of a pain to write out in code i expect and since I am still very new I expect there is a much better way. But im fairly sure this would workWed, 26 Jul 2017 12:23:08 GMTmegabrobro