- Home /
How to rotate an instantiated object by a fixed amount before it is spawned
Hi all, I am trying to rotate my instantiated object so it is facing away from my spawner as it is currently facing into the Z axis rather than the X. I have tried:
missile.transform.Rotate (0,rotation * Time.deltaTime,0);
but this doesnt seem to work.
I have also tried re-setting the missile prefab to its original coordinates of 0,0,0 and nothing happened.
Finally I tried setting the missiles rotation to as it should be in the preview window and creating a new prefab with it.
Can anyone tell me how to reference the instantiated object (as I think that i may be referencing the parent object by mistake.) Otherwise can someone please shed some light on this?
Thanks
Answer by OoglyWoogly · Apr 06, 2011 at 06:23 PM
Again I have fixed it immediately after posting. Oops. I used this:
function Start() { transform.Rotate(0,90,0); } on the missile itself to rotate it as a one time thing before it spawns. Thanks
Answer by Ben Holmes · Apr 06, 2011 at 06:23 PM
The Instantiate method has an override which accepts an initial position and rotation as well as the object to instantiate. Using this you can place and rotate the object while you're spawning it so you don't have to update it later.
Your answer
Follow this Question
Related Questions
Anyone know why this isn't working? 1 Answer
Rotate "ghost object" then instantiate object with that rotation 1 Answer
Rotating a sprite toward the mouse position on instantiation. 0 Answers
Rotate an Instantiated GameObject a set amount from another instantiated GameObject? 1 Answer
Having trouble instantiating a gameobject with rotation 0 Answers