So I have a scene where the floor is made up of some tiled objects. All of these have the exact same height and exact same Y position. I also have a block with a rigidbody that you can push on the ground. It has a rigidbody with freeze rotation enabled for X, Y, and Z.

My issue is this: when pushing the block around, it sometimes gets stuck when reaching the seams of the tiled objects. I have tried giving it a friction of 0, but it still gets stuck sometimes. Is there any solution for this, other than manually creating a big collider that spans the entire floor?

alt text

  • \$\begingroup\$ You could change your methodology to, instead of locking rotation, fire raycasts down from the cube every physics frame to see if the touches the floor and apply gravitational force if it doesn't? A suggestion if you don't find an answer \$\endgroup\$ – Coburn Aug 7 '17 at 21:02
  • 1
    \$\begingroup\$ Bennett Foddy gave a good talk on game physics engines where he explains why this happens and what you can do about it. \$\endgroup\$ – DMGregory Aug 7 '17 at 21:11

By far the most efficient solution is what you said: combine the tiles into a single collider. You can do this manually, or write a script to automatically merge adjacent colliders into bigger boxes. There are a few existing questions about this latter approach.

If that's impractical for your case (say, tiles are created/destroyed/moving frequently) then the next best thing is to give your pushables a tiny bit of a radius. You can build a cubic cage of narrow capsule colliders, with box colliders inside. This means when you get a phantom collision with the seam, the curvature of the collision on your pushable will help it ramp up and over, instead of getting stuck. It's more colliders that way, of course.

One last thing you can try, as suggested in the Bennett Foddy talk linked above, is add an extra collider right along the seam, to help catch the penetrating shape from below instead of edge-on.


I recently had the exact same problem where it was entirely infeasible to combine colliders. Here is a fairly easy to implement and very effective solution:

Disable collision checking for edges that shouldn't ever be hit. In your case, the edges between the should never actually be collided with, so why check them at all?

It should just be a couple extra checks on initializing the tiles (and on ticks, if they move) to see which edges are "collidable", and then in your collision checker just ignore the unmarked edges

  • \$\begingroup\$ I may be mistaken, but I don't think Unity's PhysX API directly exposes the ability to turn off particular faces of a box collider. But you could replace the box colliders with quad mesh colliders containing only the top face. There's a slightly higher risk of tunnelling in this case since the collision surface is infinitely thin, but it's manageable. \$\endgroup\$ – DMGregory Aug 9 '17 at 18:59
  • \$\begingroup\$ Yes, you're probably right. I probably should have mentioned that I wasn't using Unity (was using my own custom physics engine). I was thinking that perhaps the same idea could be applied here but if it's not feasible then I guess it's not a great option. \$\endgroup\$ – rococo Aug 9 '17 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.