Categories
Game Creation Mastering Development

(Unity3d) Colliders slightly intersecting each other; any solution?

Consider this simple scene:
enter image description here

In Unity3d, colliders slightly intersect each other. Typically, this isn’t a problem. However, I want to make a custom character controller using a box collider and not a capsule collider. In the above scene, the floor is divided into 2 objects, each with their own collider. The playercontroller has their own box collider.

And the problem: if the box collider moves forward, it will clip with the seam on the floor, even though both floor objects have the same height. The box will stop moving as if it has run into a wall. If I keep adding force to the box, it will never move forward. It will stay stuck on the seam– this only exists because the box is slightly inside the first floor collider, and it will hit the second collider of the floor like a wall.

This only occurs because of collisions clipping. With most playercontrollers, a capsule collider is used and thus this problem doesn’t exist.

Is there a workaround? How can the box smoothly move across the floor without colliding with the seam?

Notes:

  • This does occur with capsule colliders but rare and is not very noticeable.
  • A possible solution would be to merge all the colliders of the scene into one, unified collider. It is extremely tedious and has its drawbacks.
  • This occurs if I am moving the collider with both MovePosition(), AddForce(), or modifying the velocity/position of the transform.

Leave a Reply

Your email address will not be published. Required fields are marked *