Unrealistic gap between two objects.

Look at this picture, and please tell me why the upper square wont fall down to the “ground” underneath it. Both are box colliders2D, with the size 1, 1. And they have a rigidbody2D. The upper one have a gravity scale of 5 and a mass of 99, the lower one has is kinematic. Other than that, the rigidbody2d is just standard for both of them.


I googled around and apparently someone found a work around that worked for them:

Apparently if you use edge colliders instead of box colliders, your problem will go away.

Ok so here’s the correct solution, go to Edit–> Project Settings–> Physics2D, there change the ‘Default Contact Offset’ value to the least value i.e. 0.0001.

The reason why that gap exists is due to the fact that there is a contact offset set to a value 0.01, which allows to colliders to not contact completely. I just figured it out, hope this helps!

It all depends on what you have. Either way it’s an easy fix. If those are sprites or textures then what’s happening is that they don’t take up the whole image. If you used unity’s own cube object for those blocks then just shrink the boxCollider2D of the top cube on the Y axis a little. Remember shrink the collider and not the ACTUAL object. After you make it smaller just move the collider upso that the top of the collider matches the cube. 2 easy steps and it’s fixed.

try fiddling with Min Penetration For Penalty value found in Edit->Project Settings->Physics 2D. A lower value of 0.001 rather than 0.01 fixed the problem for me.