- Home /
Why Box Colliders 2D does not touch ?
Hello everybody,
I was playing around with Unity 2D physics engine and I was wondering why the colliders slightly float upon each other.
Here is what I'm talking about (Scene view while the game is running):

As you can see the Blue square floats above the Yellow rectangle altough the physics engine acts as they are colliding.
The Blue square has a Rigidbody 2D and a Box Collider 2D while the Yellow rectangle has just a Box Collider 2D and everything has the Transform scale set to X: 1, Y: 1, Z: 1, the Blue square sprite has a size of 32x32 pixels and the Yellow rectangle sprite has a size of 128x16 pixels.
I've made a project from scratch just to test this, so everything I am using has its default values, even the sprites have been imported with Unity default values (Pixels per Unit: 100).
I'm using Unity 4.6.2f1
Is there something I am doing wrong ? Is it fixable or is this working as designed ?
Thank you for your help !
Can i see the inspector of the blue square to check the rigidbody2d?
There you have it !
The Blue square is on the left, the Yellow rectangle is on the right !

I built the same thing in same version and it works fine, try this. http://1drv.ms/1BgLn$$anonymous$$C. If $$anonymous$$e doesn't work, send me yours.
Thank you for your quick response ! If in your project you zoom in at the rocky square you can see that they are floating too.
Very true, when zoomed in so far in scene view, but in game view my camera does not pick this up. This will be due to the automatically applied box collider, if you want it to be pixel perfect when zoomed in that much you will have to edit the collider slightly. http://gyazo.com/81e69589c09f5c32a794d288b6090f36
Answer by SirMalarkey · Feb 26, 2015 at 02:49 PM
This error is do to the way the physics engine works, if you adjust the bounds of your box collider to be slightly smaller than your sprite. It will not be noticeable.
I see, thank you for your quick response.
I'm having much less empty space just by reducing the collider size by 0.01 so I understand that this works as intended and needs just some manual fine tuning.
Your answer
Follow this Question
Related Questions
how to make a 2d character three-dimensional? 1 Answer
2D random shooting problem with velocity, 0 Answers
Dash towards cursor 1 Answer
Unity 2D Bend Sprites between HingeJoint2D 1 Answer
Diagonal movement 1 Answer