# Objects with box colliders not interacting as expected

I’m working on a sokoban-style box pushing game, and I’m finding that in some specific circumstances my boxes are getting caught on the barriers that make up the walls.

Every object here has a frictionless physics material, and my playerController script uses velocity in order to push the boxes, so no issues with setting the transform directly. My player is able to push the boxes partially into each other, which normally doesn’t cause a problem. But when these boxes in turn push into a barrier, the middle box is able to move into the space of the barrier without being pushed back out. I’ve attached a screen recording of the setup with the inspector for pertinent objects shown.

The barriers have a size of 0.9 with boxCollider sizes set to 1.111111 (I’ve also tried 1.111112).

Thank you so much!

This looks like a result of two boxes snagging each other at their corners. Something that may help is to make sure you have zero friction involved. By default the amount of friction applied is taken from both colliding object’s physics materials. So even if you remove friction from one collider you may still have friction on the another. To fix this you can edit the physics material of the orange box and set the ‘Friction Combine’ setting to Minimum.

Also, use AddForce to move your boxes around…

BTW - if the above doesn’t help then you could bevel your orange boxes to prevent them from snagging.

Hi zulo, thanks for your help!

The boxes don’t have any movement code, only the player is being moved by velocity changing, because I wanted really sharp movement. The boxes are being moved just by nature of having rigid bodies and being pushed against.

Both the boxes and the barriers have the same frictionless material on them that has friction combine set to negative.

Beveling the boxes might be my best option, but I still don’t understand why they are moving into each other like that.

Thanks,
Gage

You’ve set Friction Combine to negative? Is that a secret setting I’ve not seen?. I’ll assume you meant Minimum.

You could also try adding a little random force to the cube as you push it. This should help to unsnag it.

``````rb.AddForce(Random.onUnitSphere*0.05f);
``````

To help you understand what’s happening - some of the faces from the touching cubes are facing in exactly opposite directions along the direction of travel and so your cube’s velocity is being deflected in the opposite direction that you’re pushing it. This could also happen in reality if you slid a perfect cube along other perfect cubes. Although in reality we don’t have perfectly sharp cubes and we don’t apply perfect forces to things.