Hello
Is it possible to ignore collisions with all objects/colliders EXCEPT some with specific tags?
Is there something like:
Physics.ignoreCollisionsObjects(); // ALL are ignored
Physics.ignoreCollisionsObjects( tags, false ); // except those with those tags
Which will work for existing objects and not yet created ones.
Until now I use this piece of code:
function ignoreCollision(tag : String) {
var objects = GameObject.FindGameObjectsWithTag(tag);
for (o in objects) {
if (o.GetComponent("Collider") o != gameObject)
Physics.IgnoreCollision(collider, o.collider);
}
}
and
ignoreCollision("Boundaries");
ignoreCollision("Enemy");
ignoreCollision("Obstacle");
ignoreCollision("Trigger");
But if the tags change I must change all the tags names or add new ones in the code source.
Also there is a big issue with this code: if an object is build AFTER ignoreCollision() was called the new object will not be ignored.
Do you have a better idea?
Unfortunately, there is no way to apply IgnoreCollision in bulk. The method you are using is as good as any.
The problem with the actual method is that if you want to ignore collision with an “Enemy” and one is created AFTER you call the ignoreCollision this new enemy will not be ignored. Hence you must recall this method for all objects that need to ignore this enemy!
IMO the ignoreCollision(tag) should ignore collisions even for object with this tag created after the call aka ignore objects containing a particular tag.
Wouldn’t this be easier?
Also I think that an ignoreAllCollision() would be useful 
what might be a solution to your issue is to create a global array for each tag itself, then when something is created, have it add itself to that array. Then by referencing the array, you won’t have to re-find that array for each object that’s using it. Then to clean the list, simply have a separate script that updates the array once in a while.
You can ignore all collisions for a given rigidbody by setting its detectCollisions flag to false.