- Home /
Question by
Omar47i · Apr 27, 2014 at 04:50 PM ·
tagsfindgameobjectswithtag
Exclude my gameObject tag from FindGameObjectsWithTag
now what i want to do is to get an array of GameObject with the function call FindGameObjectsWithTag, my problem is that i have the same tag name that i'm looking for, how can i ignore my tag name and get only results from other game objects (like put a layer of ignoring myself when searching) ?
Comment
Best Answer
Answer by robertbu · Apr 27, 2014 at 04:58 PM
You cannot exclude it, but it is easy to ignore it. Something like:
var gos = FindGameObjectsWithTag("SomeTag");
for (go : GameObject in gos) {
if (go == gameObject) continue;
// Do processing on other game object here.
}
Or if this array of game objects needs to be passed elsewhere, just set the entry for the current game object in the array to null and check for null elsewhere.
Answer by Red Titan Studios · Apr 27, 2014 at 05:32 PM
Using layers would work perfectly. Or you can change your own tag.
Your answer
![](https://koobas.hobune.stream/wayback/20220613143714im_/https://answers.unity.com/themes/thub/images/avi.jpg)