Using Lerp with 2d only moving partially

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;

}

}

With MoveTowards() you can change line 24 to:

if (currentPosition == waypointPos1.position) hasFinished = true;

For Lerp() used this way, you need something a bit different because it can take a very long time to reach the goal after it is close to the goal. For Lerp() replace line 24 with:

if (Vector3.Distance(currentPosition, waypointPos1.position) < threshold) {
    transform.position = waypointPos1.position;
    hasFinished = true;
}

‘threshold’ is some smaller value like 0.1 that looks right for your particular setup.