I used the code below to instantiate the first object in an array in one of many positions I created using a vector array.
Another script I have destroys the instantiated object when it is touched.
When the object is destroyed, I want to repeat the script below to instantiate a second object, and be able to repeat the process. How do I go about doing this?
function Update()
{
var num : int = Random.Range(0,vectorArray.Length);
Instantiate (object[0], vectorArray[num], transform.rotation);
gameObject.active = false; // This ensures that the instantiation only occurs once
}