I know that the script is accessing it after every clone, but how am i meant to delete a asset that is being used in the script? I dont want it in the scene after a few seconds. (player has to dodge them)
Thanks
var theObject:GameObject;
var maxPosx:float = 2.898618; // x axis
var minPosx:float = -1.89557; // x axis
var delay:float = 0.5; // delay each spawned item by 0.5
var maxPosy:float = 5.086665; // y axis
var minPosy:float = 5.086665; // y axis
var lifeTime = 1.0;
function Start(){
StartCoroutine(spawn());
}
function spawn() : IEnumerator {
for (;;) {
yield WaitForSeconds(delay);
var theNewPos= new Vector3 (Random.Range(minPosx,maxPosx),Random.Range(minPosy,maxPosy),0);
var go : GameObject = Instantiate(theObject);
go.transform.position = theNewPos;
Destroy(theObject, lifeTime);
}
}