Hello all,
Trying to move a gameobject using lerp. The result I’m getting is that the object moves instantly to the required position rather than over time.
IEnumerator MoveToSpot()
{
Gotoposition = new Vector3(transform.position.x, transform.position.y + 5, transform.position.z);
float elapsedTime = 0;
float waitTime = 3f;
currentPos = transform.position;
while (elapsedTime < waitTime)
{
transform.position = Vector3.Lerp(currentPos, Gotoposition, (elapsedTime / waitTime));
elapsedTime += Time.deltaTime;
}
return null;
}
Would really appreciate the help!
<3