Hi there, I'm trying to create a function that allows (with the mouse click) to instantiate a gameObject from an array... whilst destroying the previous, in other words cycling through an array of gameObjects.
This instantiates from an array, but I can't work out how to Destroy the previous
Instantiate returns a reference to the instantiated object. As long as you have only one object alive at each given time you can save that reference in order to destroy it, and do something like this:
BTW - a nifty trick to use in situation where you have an array and you want to iterate over it using the index and loop is:
answered Apr 27 '11 at 11:59 AM