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
↧