How to eliminate gaps between 2d colliders?


This is something that other people asked and got an answer, but these solutions are not good so there must be another way, because if there isn’t, i think it should be changed in the next version, somehow, so it works in all projects.

Every time i try to use colliders, in my pixel art project, there are always gaps between objects. All the sprites use 100 pixels per unit and i use a RigidBody2D and a 2d box collider on the object(i tried with different colliders and i always get the same result).
Here’s what happens:


(Two different sprites with box colliders with a big gap between them)

I know that there are some ways of “fixing” it but they cause other problems. Here are some of the solutions i’ve found and, in my opinion, their flaws:

  • Smaller colliders - This might not work in some cases, i have to test and tweak the values a lot (because there are some advanced pixel art sprites) and it doesn’t seem right to do it this way

  • Scale the sprites up - This can be done by decreasing the pixels per unit value but that causes the physics to act badly, so i would have to change the physics values as well

I could use one of these but i would have to change a lot of things to make it work. So my question is, is there a better way of doing this without getting gaps between 2d colliders?

As i said before, if there isn’t, i think it would be nice to be able to change the “Min Penetration For Penalty” of the 2d collisions just like in the 3d physics manager (i’m not sure if this would work as i think it would but it’s just a suggestion).

Since i couldn’t get any other solution and there is a suggestion that mentions the Min Penetration For Penalty for Physics2D (here), i changed my mind and i will have to use a lower pixel per unit value (1 pixel per unit), while this feature is not in Unity, and to fix the gravity problems i changed the value in the Physics2D settings from -9.81 to -981 and i haven’t got any problem.

You can find the answer here