# Use Vector3.Lerp to move an obj without slowdown

Hi.
I try to use part of code i found on the forum, to move an object to a predetermined point(i use another gameobject).
The gameobject seems to be move correctly, but the linear movement without the “slowdown” dosen’t work. the object run fast at the beginning but when is close to the endPoint (the other GameObject), have a slowdown.

this is my Code:

``````shoanim : Transform; // my actor.
target : Transform; // the gameObject use for the endPoint.

function Start(){
moveTo(shoanim , shoanim , target , 400);
}

function moveTo(thisTransform : Transform, startPos : Transform, endPos : Transform, time : float){

var i = 0.0;
var rate = 1.0/time;

thisTransform.rotation = endPos.rotation;

while (i < 1.0) {
i += Time.deltaTime*rate;
thisTransform.position = Vector3.Lerp(startPos.position, endPos.position, i);
yield;
}

print ("I'm at the same place as the other transform!");
}
``````

thank you for anyone help me

You’re continuously using the new position of the transform inside the loop. You should use two fixed points instead, such as the code here: can someone explain how using Time.deltaTime as 't' in a lerp actually works? - Unity Answers

As Eric5h5 points out, StartPos isn’t actually the starting position – it’s a really awkward way to say where you are now. One fix would be just to rewire so StartPos really is a fixed position, by having start/end be Vector3s:

``````moveTo(showanim, shoanim.position, target.position ... );
//new part: look up position of start/end

function moveTo(moveMe: Transform, startPos: Vector3, endPos: Vector3) { ... }
// new part: start/end are V3s
``````

Vector3’s are copied when you run `moveTo`, so it locks down your starting position. Transforms aren’t copied (they just aren’t – it’s an odd rule,) so in your way `Startpos.position` wasn’t locked down – it was a link to your current position…