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
- Texture Import Warnings are obscured by other Terrain Layer options in the Inspector
- Burst Inspector middle divider is jittering when resized with the Burst Inspector window docked
- JsonConvert conversion fails trying to call GetCallbackMethodsForType when [OnDeserialized] is used in a class
- Different text alignment in the column header in Entities "System" window
- Objects with Universal Render Pipeline/Particles/Lit shader are always lit up when changing their Rendering Layer Mask
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.