Why do I get OnTriggerExit upon collision when a rigidbody is kinematic? (example)

Hi!

I have organized my game in scenes that deactivate when the player leave them (static trigger colliders), and for this I use OnTriggerExit(). Sadly, I also need to occasionally set the player (which is a Rigidbody with a BoxCollider) to kinematic in order to do an animated ledgegrab. During the time that the player is kinematic, the scene occasionally receive an OnTriggerExit() call if something collides with the player. I̶t̶ ̶d̶o̶e̶s̶n̶’̶t̶ ̶h̶a̶p̶p̶e̶n̶ ̶e̶v̶e̶r̶y̶ ̶t̶i̶m̶e̶,̶ ̶b̶u̶t̶ ̶w̶i̶t̶h̶ ̶s̶o̶m̶e̶ ̶k̶i̶n̶d̶ ̶o̶f̶ ̶p̶r̶o̶b̶a̶b̶i̶l̶i̶t̶y̶.

Edit:

I created a minimalistic example.unitypackage. In the example the game will pause when the boxes collide, which is caused by my problem: the OnTriggerExit() being called (the example is deterministic).

I ran it, and it’s mildly disturbing to say the least… If it is of any help, I changed the Collision Detection of the falling cube to Continous. After I did this, OnTriggerExit no longer fire on collision. Try if it would help your project. Why it would register as outside the trigger in the first place, I have no clue.

I got this answer from Anthony (Unity QA):

We see that this bug is no longer
reproducible with PhysX 3.3 we are
working on now.

We are planning to switch to PhysX 3.3
in the future and then this bug would
be gone.

Edit:

The bug is still there in 4.3

Hard to tell from just your description, but obviously something is exiting your object’s collider. You could try allowing the OnTriggerExit code to react only if an object with specific tags exit the collider.

For example:

function OnTriggerExit(col : Collider) {
       if(col.gameObject.tag == "Enemy"){
      //do something
   }
}