Description

Makes the collision detection system ignore all collisions between collider1 and collider2.

This is useful, say, for preventing projectiles from colliding with the object that fires them.

Note that IgnoreCollision will reset the trigger state of affected colliders, so you might receive OnTriggerExit and OnTriggerEnter messages in response to calling this.

IgnoreCollision has a few limitations:
1) It is not persistent. This means ignore collision state will not be stored in the editor when saving a scene.
2) You can only apply the ignore collision to colliders in active game objects.
See Also: Physics.IgnoreLayerCollision.

// Instantiate a bullet and make it ignore collisions with this object.