Getting an object to travel towards another

Hi,
hope someone can help with this. Currently making my first game in Unity and getting stuck along the way. I have tried to find answers to this among the script help but to no avail.

I have a ship which fires lasers towards the mouse pointer. At the moment I have the laser instantiating and also pointing to where the mouse is/was at the time it was instantiated.

var weapon_1 = Instantiate(weapon_1, transform.position, transform.rotation);	
				
//Rotate the laser to face the mouse pointer object
weapon_1.transform.LookAt(target);

However, I am stuck on the next part, making the missile move towards the mouse pointer (at the point it was clicked). Are there commands in Unity to move an object towards another? Or would it be the case of working out some complex calculation to get the correct amount to move along transform.position.x/y/z?

Thanks a lot for your help.

[/code]

You have your starting position (where it’s instantiated) and your target position (the point of clicking), you can then either:

(a) Use a laser/projectile/whatever speed and move along the line of travel (line of travel = target position - starting position)

(b) Create a starting position transform and a target position transform and then linearly interpolate between the two (lookup Lerp in the docs)

I would guess that your best bet is something like option (a), and then translate the projectile/laser/whatever’s transform along the path using the speed you specify.

cool,

thanks a lot. Option A sounds like the best bet, although not initially simple to setup.

thanks for your help.