I am trying to make a very basic waypoint system. So I decided to use Lerp for changing between positions. The problem is that when I do this the object that should be moving doesn’t “Lerp” to the place it is supposed to. So I should probably ask, using lerp, can it be called once within the update frame? Here’s the code:
#pragma strict
var smooth : float = 3.0;
var waypointPos1 : Transform;
var waypointPos2 : Transform;
var hasFinished = false;
var currentPosition : Vector2;
function Start () {
currentPosition = transform.position;
}
function Update () {
if(hasFinished == false){
transform.position = Vector2.Lerp(currentPosition, waypointPos1.position, smooth * Time.deltaTime);
hasFinished = true;
}
}