Hi everyone,
I’m trying to make an object rise through the floor of my game, and to accomplish this I’m trying to use a Vector3.Lerp. Unfortunately, no smooth movement happens. The object simple snaps to its end position immediately. Here is my code:
var animationDuration : float = 2;
var time : float = 0;
var damper : float = 1.5;
function Update()
{
Rise();
}
function Rise()
{
var startPosition : Vector3 = this.transform.position;
var endPosition : Vector3 = Vector3(this.transform.position.x, (this.transform.position.y + 10),
this.transform.position.z);
yield WaitForSeconds(2);
while (time < animationDuration)
{
time += Time.deltaTime;
this.transform.position = Vector3.Lerp(startPosition, endPosition, time * damper);
}
}