Search code examples
unity-game-enginecollision-detection

Collisions are not being detected correctly


I'm having trouble with collision detection in Unity. Specifically, when the collision is clearly entered, the OnCollisionEnter method doesn't get called, and magically it only be called when I do some action in Unity Editor, for example, navigating from the Game tab to the Scene tab. I know it sounds magic, so I recorded a video here.
This issue doesn't appear if I set the Collision Detection property in Rigidbody component of the Robot to Continuous Speculative, but as you can see, that robot's velocity is super slow and I have no reason to choose the most expensive option.

Is there any other way to solve it?
Thanks.


Solution

  • I found the reason, it was because I made the Character Controller component overlap the Sphere Collider component. And somehow, the collision between Block and my character is always detected by the Character Controller instead of Sphere Collider. So the solution is to make the Sphere Collider little bit bigger than Character Controller

    enter image description here