- Home /
Destroy by tag problem
Hi,
I have a problem with destroying array of prefabs that have been instantiated. I tagged those objects with "spawn", and when they collide with main character, the tag changes into "picked" and they become children. But
Destroy(gameObject.FindWithTag("spawn"), 20);
works even after tag changes, and they get destroyed anyway.
Can anyone help me with this?
Answer by Yanger_xy · Jul 11, 2011 at 09:48 AM
Do you mean that you can find the gameobject with its old tag(spawn) using function gameObject.FindWithTag("spawn") even though you have changed its tag to a new one(picked)? If so, check whether there are something wrong with your collision, and be sure that the gameobject has been assigned a new tag ("picked") Good luck!
I have checked everything, and object "spawn" becomes child immediately after collision, and changes tag into "picked". I always check everything in the Inspector panel. This is so weird and i realy don't know what to do...
Problem solved :)
http://forum.unity3d.com/threads/96241-Destroy-by-tag-problem
Your answer
Follow this Question
Related Questions
Destroy multiple game objects when player press a button 2 Answers
How can I make this object destroy on Collison? 1 Answer
move between unique tags 0 Answers
Fixing problem with collisions. 0 Answers