Colliders 2d apparently touch each other even if they should not.

Hi everyone, i’d like to ask you about a problem i ran into, relating to colliders. The title is explanatory…
reminder: we’re talking about physics and collider 2D (the new tools).

The attached image shows in the bottom part, the Player colliders (typical sphere for the feet and rectangle for the body) and a Ground on the left.
The Ground has two colliders: one of the Ground shape (with some material and friction) and a outer one just on the edge ( small rectangle with no friction). This is done for preventing the player to stuck on the ground side if some force is applied (during movement while falling for example).

If you look at the bottom part of the image, you may notice that the player collider got stuck…bringing the character to the edge and letting him fall MAY after some attempts results in this scenario.
You can’t still notice, but the sphere, if you zoom in, isn’t really touching anything.

In fact looking at the image above, I’ve removed at runtime the sphere collider and discover that the collider causing the block is the rectangular one.
As you may notice it’s not touching anything, nor any input is given at this point.
I use a simple script (inspired by the last unity 2d lesson) for player control, and collision detection. Anyway this should be irrelevant.

So summing up:

  1. Seems that an external collider (the circle) does not cover the inner one (the rectangular) as intuitively expected. It seems that the rectangular collider got stucked by himself.

  2. Also…the colliders aren’t touching, but the player’s one is still on the air. Is this a gui problem?

Any help would be really appreciated…
Thank you in advance :slight_smile:


Take a look at Physics Manager on Project Settings: in particular try to ajust Min Penetration For Penalty and Solver Iteration Count

Let me know!

Well, I found out the answer to this. The issue is that while the first collider you’re on decides that you should be pushed out of it upwards, the collider you start going over next sees that you’re more on side of it then the top and decides the shortest path to push you out of the collider is backwards, so you get stopped. The solution seems to be to use Edge colliders to build your surface instead. Make your cube out of them and it seems to work perfectly! (plus you can then define the sides as the Wall layer and the top as the Ground, simplifying level design even more.

MelvMay pointed it out in this thread:

Including a useful link about the issue.