Search Issue Tracker
By Design
Votes
0
Found in
2018.4
2019.4.3f1
2020.2
Issue ID
1263380
Regression
No
OnCollisionExit callback is called when a Rigidbody is still in collision with non-convex mesh collider
How to reproduce:
1. Open the attached "CollisionCounterTest_Reduced.zip" project
2. Open the "SampleScene" Scene
3. Make sure the Console log is visible
4. Enter Play Mode
5. Drag the Gun GameObject( white rectangle) down on the Y Axis so that it collides through the big flat box (with a non-convex mesh collider)
6. Once the rectangle's centre (visualised by a thin ring around the rectangle) passes through the mesh collider, OnCollisionExit will be called
7. Observe the Console log
Expected result: OnCollisionEnter and OnCollisionExit callbacks are called when the "Gun" GameObject has begun/has stopped touching the "Cube" GameObject's Mesh Collider
Actual result: OnCollisionExit callback is called even though the "Gun" GameObject is still inside the "Cube" GameObject's Mesh Collider
Reproducible with: 2018.4.26f1, 2019.4.8f1, 2020.1.2f1, 2020.2.0a20
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
- Profiler - Taking you to the wrong section when using 'show'
- Draw Renderers custom pass doesn't work with SSGI
- WebCamTexture does not set the requested resolution when used in WebGL
- Editor default Stylesheet/Matching Selector buttons in Debugger don't do anything
- Graphics.DrawMeshNow stops rendering Render Texture after a few frames when viewed in the Player
Resolution Note:
The non-convex mesh collider does not really have a concept of "Inside" and "Outside" of a mesh. You could get the same result with a plane that your object passes through. Once the center of the object is on the other side of the mesh collider, there is nothing to collide with anymore and it reports a lost touch (OnCollisionExit)
We state this in our documentation: "Faces in collision meshes are one-sided. This means GameObjects can pass through them from one direction, but collide with them from the other."
If there is a need to report collisions from the inside of a mesh, then a convex mesh collider should be used.