|
Hello. How can I destroy all objects with a certain tag? I tried to do something like this, but It doesnt work.
EDIT -Updated the script, still doesnt destroy all of the objects with that tag.
(comments are locked)
|
|
You just need to iterate through the array elements instead of trying to access the array itself. So, instead of
you will need to use Thanks, but it still doesnt destroy all of the objects with that tag, just that one specific object.
Nov 30 '10 at 05:52 AM
Tyler 2
Hm, looking at your script you posted, I wonder whether the script is thrown off by your use of
Nov 30 '10 at 10:29 AM
xeophin
(comments are locked)
|
|
This is also in answer to your similar question here. You can acquire an array of references to all the active game objects in the scene with a specified tag using GameObject.FindGameObjectsWithTag(). Once you have this array, you can check its length to see how many such objects there are. You can also perform operations on the list of game objects as needed (for example, destroy them all using Destroy(), activate or deactivate them, enable/disable specific components, etc.). I tried to implement something like that (or atleast something that sounds like that) in my edited question, But I am completely lost.
Nov 29 '10 at 06:40 AM
Tyler 2
(comments are locked)
|
