|
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
(comments are locked)
|
|
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: That little trick is something i've been needing for ages! and that solution worked perfectly. Thankyou!
Apr 27 '11 at 12:18 PM
Caiuse
Small side note: instead of going crazy saving the instantiated object reference just do oldObject = newObject; newObject = Instantiate(stuffz). Now you can destroy the old object or do.. what ever. ;)
Apr 27 '11 at 12:34 PM
Joshua
(comments are locked)
|
