How do I fix the bug where my Rigidbody gets stuck on the edge of two Colliders?

How do I fix the bug where my Rigidbody gets stuck on the edge of two Colliders?

The boxes are standing right next to each other, but somehow, the player manages to collide with the ghost edge. I use AddForce to control the player with a Box Collider, though I also tried using a Mesh Collider, and I tried setting the player's collision to continuous. This also happens in 2D.

I've seen other people's posts about this bug, but I couldn't really understand how to fix it. How do I fix this?

Solutions/Answers:

Answer 1:

I think I had a similar issue in 2D. Try replacing your Box Collider with a reasonably sized sphere or capsule.

In 2D, I ended up using a Circle Collider with a smaller Box Collider. The Circle Collider made it so that my player didn’t get hung up on the floor and walls that were composed of discrete boxes (with associated Box Xolliders). I added the smaller Box Collider to the player, because as a 2D platformer, I did not want my player to slide off the edge of obstacles.

Answer 2:

Try changing the material of your box colliders. Also, I found a similar thread in Unity forums. That’s about 2D, but the problem seems to be the same.

References