Unity Move Object with Lerp

Unity Move Object with Lerp
You can use Lerp function to move an object automatically. You just need start and end points. Object moves from start to end in time. You can assign start point and end point manually in script or with mouse click. These points may be another objects positions too. Just assign these points, attach this script to an object and let it move.

private float time = 2.0f;
 
 void Update () {
  Vector3 startPoint = new Vector3 (0, 0, 0);
  Vector3 endPoint = new Vector3 (0, 0, 3);
  transform.position = Vector3.Lerp (startPoint, endPoint, time);
  }

Unity Move Object with Lerp