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
- "Shader warning in 'Hidden/Light2D': implicit truncation of vector type" is thrown when building Universal 2D template
- AI Assistant breaks compilation of packages using System.Runtime.CompilerServices.Unsafe via auto-referencing
- Unity Hub checks the "Documentation" module by default on the 6.4 and 6.5 streams despite that it was unchecked with the previous installs
- Shortcut that toggles between Dopesheet and Curves Views in the Animation Window's Timeline is mislabed
- Property List Items Overlap onto the Property List's top edge when scrolling through a long Property List
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.