Make a game object move towards another object and continue its path.

I dunno if the title is clear enough.

I want a game object to move towards another game object but once it reaches the object i want it to continue on its path in the same direction/alignment.
I have been trying to find a way to do this for a while now and i am stuck.

thanks

Supposing you want to use Update, and the object will start moving when “Fire1” is pressed, you can use the script below (attached to the moving object):

var target: Transform; // drag the target here
var speed: float = 5.0; // object speed
private var moving = false; // object initially stopped
private var dir: Vector3;

function Update(){
  if (Input.GetButtonDown("Fire1")){ // if Fire1 pressed...
    dir = target.position - transform.position; // calculate the target direction...
    moving = true; // and enable movement
  }
  if (moving){ // if movement enabled...
    // move the object in the calculated direction (world coordinates):
    transform.Translate(dir * speed * Time.deltaTime, Space.World);
  }
}

The object will start moving in the target object when Fire1 is pressed. The object will continue moving in the same direction, even if the target has moved from there. If Fire1 is pressed again, the object will turn to the new target direction and continue moving.

You will definitely find the answer these are just 4-5 minute clips.