How to find the transform position of another gameobject then move a gameobject to that position?
Hi!
So basically I'm making a missile launching script for my airplane racing game. After all, who can fly an airplane without shooting at someone with missiles?
So I need to do 2 things: 1: Keep missile under the airplane's wing (that's why I need to find the position of another gameobject) 2: Make it move WITHOUT affecting the airplane (meaning I can't make the missile a child of the airplane, else the plane's movements will change the missile's movements).
So how do I find the position of another game object then set my missile's position to that?
THANK YOU!
Answer by StephanT · Feb 12, 2016 at 01:30 PM
In Inspector: Create an empty Gameobject with airplane as parent. Move the empty Gameobject to where the missile should be.
When missile is fired: Create new missile Gameobject from missile Prefab. Move it to the position of the empty Gameobject from above.