# Lerp acting weird when iterating through Transforms

So I’m working on this moving platform for a side-scrolling platform game and I’m having some trouble. The way that it works is that there is an array of transforms that I can define in the inspector which the moving platform moves towards in rotating order. Kind of like [this][1] but with only one platform.

The problem is that this: when it starts the platform moves along fine towards its next destination, but when it reaches there it cycles through each destination super fast.

Here is my code:

``````var dests : Transform[]; //Array of destinations for the platform defined in the inspector
var start : int;
var curr = 0; //The last destination platform
function Start () {
transform.position = dests[start].position;
}

function FixedUpdate () {
var prevDestination : Transform = dests[(curr)%(dests.length)];
var destination : Transform = dests[(curr+1)%(dests.length)];
transform.position = Vector3.Lerp(prevDestination.position, destination.position, Time.time);

//If the platform is at the destination, move the current destination up one
if(transform.position == destination.position){
curr++;
Debug.Log(transform.position+"|"+prevDestination.position+"|"+destination.position);
}
}
``````

The perplexing thing for me is that it works the first time, but then it hyper-glitches once it reaches its first destination.
Tell me if you have any questions. Thank you in advance!
[1]: http://i1.ytimg.com/vi/dM-xKbLH8SY/mqdefault.jpg

The third parameter in Lerp is a float between 0 and 1; using Time.time is virtually never appropriate, because it won’t work past the first second. The point of Lerp is that you increase that third parameter from 0 to 1 and then stop; you wouldn’t compare transform.positions. Also FixedUpdate is for physics and not something you’d use for this. See here for an answer about how Lerp works.