object2.transform.position.x = 50, but when it lerps object1 goes straight to this point (x=50),but never reaches it.It stops on 49.9999. I need object1 to reach exactly 50. How to make it ? Maybe there are some ways to stop lerping ?
I was thinking to make like this.

“Lerp(from, to, t) interpolates between from and to by the fraction t. When t = 1 returns to. When t = 0.5 returns the point midway between from and to.”

So, to actually ever get to the end value, to, the third parameter must be 1 (or greater). Your code is passing Time.deltaTime*speed. Unless speed is greater than your framerate per second (which, from your description, I’m assuming it’s not), this value is always going to be less than 1. So on every frame you move a fraction of the remaining distance closer to to, but never quite get there.

You’ll also experience other problems from using this approach - the movement itself will not be linear - the distance covered in each step will decay (fast at first, then slow down as it approaches, which may or may not be what you want).
You’ll also be making your movement framerate dependent, so that the rate of movement varies on different machines, which you almost certainly don’t want.

If you use Lerp the way you have then it gets slower and slower as it gets closer, and hence never reaches. It’s one of Zeno’s “paradoxes”.

[Note - technically, since we’re talking about discrete quantities rather than theoretical tortoises, it would get there eventually, in that the distance would get to be less than Mathf.epsilon. But how long this takes depends on the interpolation fraction and it can be a very long time].

The simplest fix is simply to check the distance between the 2 positions after the Lerp call, and if it’s less than some (small) threshold of your choosing, set the moving object’s position to that of the target.

You could also use Lerp the other way, using starting position as the first param and a cumulative time for the interpolation fraction. Then it’d stop because your interpolation fraction would reach 1. But you’d have to find another way of making it slow down as it got closer.

create a static class without mono behavior
then use this function

//interpolate an object from A to B over a fixed time
public static IEnumerator Interpolate(Transform obj, Vector3 destination, float overTime)
{
Vector3 source = new Vector3(obj.position.x,obj.position.y,obj.position.z);//deep copy
float startTime = Time.time;
while(Time.time < startTime + overTime && obj != null)
{
obj.position = Vector3.Lerp(source,destination,(Time.time - startTime)/overTime);
yield return null;
}
obj.position = destination;
}

Then from anywhere in any other class:
StartCoroutine(NameOfTheStaticClass.Interpolate(theObjectTransformToMove, vectorEndPos, timeOfTheInterpolation));

and if you start this coroutine from a coroutine, you can wait for it to end like that