- Home /
 
 
               Question by 
               Tyler 2 · Jan 16, 2011 at 09:34 PM · 
                movementinstantiate  
              
 
              Instantiate transformation?
When you instantiate an object, is there anyway to add a transformation to the object (so you can create an exploding type effect) using the script that is instantiating the object? Or would you have to attach a separate script to the prefab that you are going to instantiate (if that is the case. how can you instantiate objects and make the objects face a random direction)?
               Comment
              
 
               
              Answer by _Petroz · Jan 16, 2011 at 10:42 PM
All GameObjects have a Transform so you don't need to add one. You can specify the position and rotation inside the Instantiate function like this:
var prefab : GameObject;
Instantiate(prefab, Vector3.zero, Random.rotation);
 
               
               http://unity3d.com/support/documentation/ScriptReference/Random-rotation.html
Your answer