Comments and answers for "Object slows down when moving to a NavPoint, speed is not constant"
http://answers.unity.com/questions/456316/object-slows-down-when-moving-to-a-navpoint-speed.html
The latest comments and answers for the question "Object slows down when moving to a NavPoint, speed is not constant"Comment by hoy_smallfry on hoy_smallfry's answer
http://answers.unity.com/comments/456344/view.html
I've converted your answer to a comment :)Tue, 14 May 2013 18:01:16 GMThoy_smallfryComment by Sarcoex on Sarcoex's answer
http://answers.unity.com/comments/456343/view.html
Adding *dir.Normalize();* before *monster.transform.Translate(dir * speed * Time.deltaTime, Space.World);* solved the problem. Thank you so very much for the quick reply. :)Tue, 14 May 2013 17:59:24 GMTSarcoexAnswer by hoy_smallfry
http://answers.unity.com/answers/456324/view.html
The closer you are getting to the target, your direction variable `dir` is getting closer and closer to zero vector (0, 0, 0). This will happen because the intent is to make `monsterPos` equal to `nextNavPoint.transform.position`; the closer `monsterPos` gets to being equal to `nextNavPoint.transform.position`, the closer `dir` is equal to `nextNavPoint.transform.position - nextNavPoint.transform.position`, which is zero vector. Because this increasingly smaller `dir` value is being used to caculate your translation, your velocity, which is "direction * speed", slows down.
The solution is to normalize your direction vector to a [unit vector][2] with [Vector3.Normalize()][3] before you use it to translate. Normalizing will keep your vector at unit size (magnitude of 1) always, no matter what magnitude `dir` originally was. Though, the movement will be rigid and constant this way.
[1]: http://en.wikipedia.org/wiki/Magnitude_(mathematics)#Euclidean_vectors
[2]: http://en.wikipedia.org/wiki/Unit_vector
[3]: http://docs.unity3d.com/Documentation/ScriptReference/Vector3.Normalize.htmlTue, 14 May 2013 17:37:00 GMThoy_smallfry