destroy object then instantiate a prefab at emptygameobject? please help

i already got my cube to be destroyed on TriggerEnter but how do i instantiate a object using a empty gameobject when the the cube is destroyed

so it should be like this…
I touch the cube.
cube destroys itself.
a object instantiates at empty gameobject or different location(instantiates ONLY ONCE)
any ideas?

1 Answer

1

All you need to do is instantiate it. First, you make a variable. Use this var for the position where the new object spawns. You might want to drag and drop that empty gameObject later. Here is an example of the code:

var objectToMake : Transform;       //You will need to put prefab in this in the inspector

var spawnPos : Transform;           //You will drag and drop on this

function OnTriggerEnter (col : Collider)
{

   //When the cube is destroyed
   Instantiate (objectToMake, spawnPos.position, spawnPos.rotation);

}

Hope this tip will help u! Cheers!