Search Issue Tracker
By Design
Votes
2
Found in
5.6.0f3
Issue ID
904813
Regression
No
OnCollisionExit is delayed by a frame
Steps to reproduce:
1. Open user attached project OnCollisionExitBug
2. Open "demo" scene
3. Hold the right arrow key until the circle hits the collider
4. Hold the left arrow key until the circle leaves the collider
Expected result: Only one frame should take to activate OnCollisionExit after leaving the Quad
Actual result: It takes two frames to activate OnCollisionExit after leaving the Quad
Reproduced in: 2017.1.0b2, 5.6.0p2, 5.5.3p2, 5.4.5f1
Comments (2)
-
davidmcasas
May 28, 2023 22:16
I can't believe this is still an issue on 2023. OnCollisionExit events are being called one physic step too late. OnCollisionStay is still called one time when the object is not colliding anymore. And that's not what users would expect.
I understand that this happens because the collisions are calculated BEFORE the physic simulation happens. But it's confusing, because on the Execution Order diagram, OnCollisionXXX events are called AFTER the physic step.
I'd like to have alternative OnCollisionXXX methods that are actually calculated after the physic step. I believe this would be the natural thing, and I would like to know what is the technical reason behind the current behaviour.
-
Tortuap
Sep 21, 2018 08:47
It is not only callbacks such as OnCollisionExit which are delayed by a frame, but also the results returned by methods Collider2D.IsTouching, Collider2D.GetContacts.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Blank, Light-Themed "Create Node" window becomes visible on the next project open
- UI Elements/Layout inconsistencies in the Particle System component
- The Game view and Scene view fail to render when launching the Editor with a maximized Render Graph Viewer window
- "List is empty" is poorly visible in the "Create Node" window
- [Android] GameObject with a custom shader becomes invisible when deployed with the Vulkan Graphics API
Resolution Note:
This is how Box2D works. It finds contacts first then performs a simulation. The new positions may produce overlaps/contacts but they won't be found until the next simulation step.