Do something when lerp reached target.

Hello.

I am using Vector3.Lerp to get to move a object to another one, everything goes well, but how would I do another task when the object reached the other one(or when it is close enough).
How would I track the progress of that lerp?

Thank you!

Your solution is probably to test the new vector whether it now is equal with the vector before.

Vector3 oldPos = transform.position;
transform.position = Vector3.Lerp(oldPos, target, dt);
if (oldPos == transform.position)
{
    // we arrived. Do some stuff here. Be sure to disable the Lerp or this
    // triggers again.
}

Yeah, figured out myself.

Its always nice to give the answer if you figure it out. Others may have similar problems. Also, you can answer your own question without problems and mark your own answer as valid. This helps people who scan for “unanswered questions”. :wink: