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
- “Remove Unused Overrides” available on not loaded Scene and throws “ArgumentException: The scene is not loaded” warning
- Adaptive Probe Volume occlusion edge is calculated incorrectly when viewing probes near geometry edges
- Sampling a texture using an HLSL file throws shader errors and the code does not compile
- "Graphics.CopyTexture called with null source texture" error when Base Camera of an Overlay Camera is removed with DX11 Graphics API and Compatibility Mode enabled
- WebGL sends wrong value with large numbers when SendMessage function is used
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.