Undoing Physics.IgnoreCollision()?

Is there any way to undo the effects of Physics.IgnoreCollision()?

For instance, I want to ignore collisions between a wall and an object for the first second of that object’s life, but then resume collision checking.

It’s easy enough to implement this logic, except that I don’t see any method to tell the physics engine I’d like to ignore the ignore (the IgnoreCollision documentation makes mention of circumstances in which the state is lost, but that seems like dangerous territory to deactivate/reactivate a rigidbody just to resume collision checks).

Physics.IgnoreCollision( yourCollider, yourOtherCollider, false );
7 Likes

D’oh! Not sure how I missed that.

On second look at the documentation page, it was kind of hidden (some of the docs pages overlap for me).

25849--939--$unitydocs_114.gif

Ha. Just the part you needed. :slight_smile:

1 Like

If anyone needs it, turning either of the relevant gameobjects off+on will reset the ignoreCollision flag
source: Unity - Scripting API: Physics.IgnoreCollision

1 Like

Please don’t necro threads. The above post is not only 17 years old but it was already answered way back then.