OnCollisionExit or OnTriggerExit with Physics.IgnoreCollision

I must be missing how these two things work. Right now I have a border made out of objects slightly off screen so when a bouncing ball hits them it changes direction randomly. I want the ball to spawn outside and move in.

Physics.IgnoreCollision gets set to true but it’s in OnCollisionEnter.

OnCollisionExit or OnTriggerExit are never called when the ball passes through, which is how I thought they were suppose to work. My assumption is that because it is now ignoring physics with that object it no longer calls either of these functions and so I can’t use them to change Physics.IgnoreCollision to false.

My question is two fold:

Is that true?

If so, what else can I do?

Triggers and Colliders are one-way; like mesh textures. If you are on the “inside” of one, then the collision will not hit. There aren’t enough details about where your colliders are at to know if this is the case.

Also, if the ball is a Rigidbody and you are trying to use a Trigger, then the ball has to be set to Kinematic for the trigger to take effect; conversely, if you are using colliders, then the collider cannot be labeled as a Trigger.

Hopefully something from this can point you in the right direction. If not, more details never hurt anyone, or a screenshot of how your border is setup.

I also got this issue and one neat way to resolve it is to do in Coroutine like the following

private IEnumerator WaitForIgnoreCollision(GameObject a, GameObject b)
{
Physics.IgnoreCollision(a.collider, b.collider, true);
yield return new WaitForSeconds(5f);
Physics.IgnoreCollision(a.collider, b.collider, false);
}

and then call it in the OnCollisionEnter at whatever condition you might need it at.