I have had a lot of problems with physic 2D events, there is the newest one scenario but samekind of problems would be in very difrent kind of scenarios.
Scenario: I have gameobject with rigidbody2D and collider, under that there is gameobject with second collider which is on trigger mode (note that these two colliders dosen’t react to each other since that is disabled by layers). Now my main gameobject goes throw another gameobject with trigger collider (no rigidbody). And of course every physic related components are 2d versions.
Now I have OnTriggerEnter, Stay and Exit functions on my main gameobject and I ESTIMATE that I get first Enter, then Stay for everyframe when colliders are inside each other and finally Exit.
But what I get:
Enter
Enter
Enter
…
Enter
Enter
Exit
And just in “you just have type in your code” case here is my event code:
void OnTriggerEnter2D(Collider2D other)
{
Debug.Log("Trigger enter");
}
void OnTriggerStay2D(Collider2D other)
{
Debug.Log("Trigger stay");
}
void OnTriggerExit2D(Collider2D other)
{
Debug.Log("Trigger exit");
}