- Home /
rotation on instantiating
i am instantiating a gameobject with a prefab , the prefab has rotation set to x= -90. But when the object is intantiated its rotation is set to 0.
Answer by Owen-Reynolds · Sep 25, 2012 at 04:57 PM
Instantiate always replaces the prefab pos/spin with the new ones you give it. It assumes the prefab Transform is just random (in other words, when you drag something in to make a prefab, you never have to worry about putting it at 0,0 and facing forwards.)
In theory, they could have had a 2nd version of Instantiate where you just give the new pos and keep the spin. But your designers "know" the prefab rotation means nothing, so better to have the code always set angles for each spawn.
All you have to know is how to say "this x,y,z spin," which is with Quaternions:
Instantiate( thing, pos, Quaternion.Euler(-90,0,0) );
It turns out in the normal Instantiate command, that last input `Quaternion.identity` is just a shortcut for `Quaternion.Euler(0,0,0)`.
Your answer