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
-
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
- Fixing Message Loss in UMPE During Domain Reload
- The Editor freezes when ScheduleReadOnly of IJobParallelForTransform with dependency is used
- Text is truncated in the Inspector when the display scale is set to 150%
- CancellationTokenSource(<timeout>) has incorrect cancellation status when used in WebGL Player
- VFX property value names are cut off when properties with 'Arc' are viewed in the VFX Blackboard
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.