this is because by nature, linear interpolation never reaches its exact goal - just very close to it smoothly, infinitely slowing to an unnoticeable speed. do something like:
if (myObject.transform.position.x > closeToDestination.x){regular transform, stop lerping, go right to destination.}
Well, it’s only doing that because it’s not being used appropriately. As the name suggests the velocity is in fact linear. The result returned for t = 0 is the exact starting position, and the result for t = 1 is the exact end position. So if you use it with that in mind you will in fact get things moving linearly between two exact points.
The reason it works as you describe here is that it is not actually being used as a linear interpolation, because t is not being changed but the starting position is. You’d typically do the opposite. That code simply moves player1 20% closer to the transform each frame.
Woody, the way that a lerp is generally used is something along the lines of the following.
When you start the lerp, store the starting position and some kind of timer.
Each frame, update the timer. Compare the timer to your desired duration to come up with your interpolation factor (a number between 0 and 1 which increases from 0 at the start to 1 upon completion).
Use the above along with your target position in the lerp function.
For bonus points, once you’ve got that working you can swap Lerp out for SmoothStep, which works similarly but eases in and out at the end. (This looks smoother if you’re using it for certain types of animation.)
Alternatively, if you don’t care about the duration and just want one thing to move towards another, you could also try using MoveTowards instead of Lerp (since you are in fact using Lerp as a kind of MoveTowards in this case anyway).
It can be a tricky one to grasp at first if you don’t already know what it’s meant to do, because it does look like it’s doing something sort of right.