Sunday, November 28, 2010

Unity Lerp Slow Down "Effect"

I've been working a little bit with Unity for this small AI project for school lately. My teammate came across an interesting "effect" when working he was using the Lerp function. Basically, he had 2 cubes in the scene and one of them, A, wants to run towards the other cube, B, at some fixed speed. The strange bit occurs when A gets closer and closer to B, A gets there slower and slower as if doesn't want to reach its destination. I noticed that we're not the only ones having this "effect" happen to, so I thought I post this for those who have the same issue. I won't go through explaining about lerp as I've found a few references worth checking out. But basically, one simple solution is to write a coroutine over lerp. For a more detailed explanation of why lerp is doing what's it doing, please check out these helpful links I've found:

http://answers.unity3d.com/questions/6949/can-someone-explain-how-using-time-deltatime-as-t-in-a-lerp-actually-works/6950#6950

http://forum.unity3d.com/threads/40059-Customized-Vector3-Lerp?p=256374#post256374

No comments:

Post a Comment