Setup for an object to move to the location of moving object

Hey All,

I want a missile to launch from the ground and hit a moving spacecraft in the air. The spacecraft isn’t going super fast, but it is still moving. What would you suggest is the best scripting approach to have the missile aim for the spacecraft while modifying it’s final position until it hits the spacecraft?

1 Like

Well, if you want the missle to always follow the spacecraft then turn it in loop

while MissleHit == false do

To launch missle make it CanCollide to false and put a any body mover in it (if it’s model then make a main part of model and put body mover in it). Read about them here. I recomend using BodyPosition but I’m don’t clearly remember if there any others which can contain position.

In loop just change body mover’s position to spacecraft’s main part position.

When missle will hit spacecraft (it must be outside of loop and NOT after it. Better put it in another script) change MissleHit value (you can create it in missle) to true so loop will stop and missle won’t chase spacecraft anymore.

1 Like

Thanks for pointing me in the right direction. I followed what you suggested and it looks like it will work out great!

If it helped you, please, mark it as solution :yum: