- Home /
Instantiated object multiple times in the hierarchy
Im making the Walker boys tutorial (The asteroid game) and, when I instantiate an explosion, it still remains in the hierarchy when is gone... so every time I destroy an asteroid, an explosion is instantiated, and remains in the hierarchy until I stop playing... is that the way it supposed to be? Iam wasting resources? How can it be killed?
I instantiate it like Instantiate(gameObject,position,rotation);
I put a screenshot of the situation.
SOLUTION: I used
Instantiate(explosion,position,rotation)
But I should use:
var clone : GameObject = Instantiate(explosion,position,rotation);
so then I can do Destroy(clone,2.0); without having the " Destroying assets is not permitted to avoid data loss." error!
Answer by lancer · Aug 10, 2013 at 04:02 PM
After the explosion in your script put this:
yield WaitForSeconds(2);
Destroy (gameObject);
Or use the optional parameter to Destory():
Destory(gameObject, 2.0);
ERROR: Destroying assets is not permitted to avoid data loss.
The GameObject is an explosion made through the Particle System.
Answer by DarkSlash · Aug 11, 2013 at 12:27 AM
SOLUTION: I used
Instantiate(explosion,position,rotation)
But I should use:
var clone : GameObject = Instantiate(explosion,position,rotation);
so then I can do Destroy(clone,2.0); without having the " Destroying assets is not permitted to avoid data loss." error!
Set your own answer as the answer to your question :) So this question can be closed.
Your answer
Follow this Question
Related Questions
Calling a variable 2 Answers
Rotate "ghost object" then instantiate object with that rotation 1 Answer
Combine objects instantiated at runtime 2 Answers
Draw a line and instantiate it as a game object 0 Answers
Instantiate as child 3 Answers