Hi Everyone,
I am making one ball game and i am trying to create obstacle’s in a dynamic way, I am using Instantiate for creating obstacles but when i am trying to Destroy my old object (clone) on that time i am facing some problems. If anyone know the solution please give reply…Thank You
If you are destroying the object from within it’s own script, be sure to call Destroy on the GameObject (GameObject.Destroy(this.gameObject);
, otherwise you’re only destroying specific components. If you’re trying to destroy it from outside it’s own script, then you need to keep a reference to it when you instantiate it, which you can then call Destroy on (for example, use: o = Instantiate(...);
followed by Destroy(o)
, where o
is a GameObject variable).