Hi guys,
I need a certain collider to ignore all colliders in my game that got the tag “ground”.
My very stupid idea was this:
Physics.IgnoreCollision(thing.collider, gameObject.tag == "ground".collider);
Of course this won’t work. Do someone has better a idea?
3 Answers
3
Using the PhysicsManager you can set whether certain layers collide with each other in the Layer Collision Matrix
You got it pretty close, you just have to iterate over the objects instead of trying to do it all in one command:
GameObject[] objects = GameObject.FindGameObjectsWithTag("ground");
foreach (GameObject obj in objects) {
if (obj.collider != null) {
Physics.IgnoreCollision(thing.collider, obj.collider);
}
}
use IgnoreLayerCollision (8,9); 8:thing object collider 9:ground tagged objects(make all ground tagged object layer as 9 layer)
– yogee