Search Unity

Is there something wrong with my Collider 2D?

Discussion in 'Physics' started by ChrisX, Mar 20, 2015.

  1. ChrisX

    ChrisX

    Joined:
    Feb 13, 2015
    Posts:
    63
    Hello, all.

    I want to ask, why is it that my two colliders always have a gap or something, like they haven't even touched each other and they already stopped travelling to each other, so there's like a gap? Is there something wrong with how I set up my collider?

    I uploaded the screenshot of how it looks like it my Scene, if you need another screenshot, let me know. Both has box collider 2D.

    Many thanks for helping!

    (Sprite taken from I Wanna Be The Guy) unity collider problem.png
     
  2. sleekdigital

    sleekdigital

    Joined:
    May 31, 2012
    Posts:
    133
    Do you have a rigidbody2d on the character?
     
  3. ChrisX

    ChrisX

    Joined:
    Feb 13, 2015
    Posts:
    63
    Yes I have.
     
  4. modegames

    modegames

    Joined:
    Dec 1, 2014
    Posts:
    37
    I would suggest looking at the min penetration value in the PhysicsManager or physics2d settings in Unity
     
  5. ChrisX

    ChrisX

    Joined:
    Feb 13, 2015
    Posts:
    63
    I did not touch that. It's at 0.01. Should I lower that?
     
  6. modegames

    modegames

    Joined:
    Dec 1, 2014
    Posts:
    37
    Yes I would try the importance of this value will depend on your scale factor of sprites to world scale
     
  7. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,452
    The value was previously fixed inside Box2D and adds a small 'skin' around colliders to stop them interpenetrating. Whilst you can now change this value (enough people asked), it is not without consequence and will affect continuous-collision detection for polygons.

    Physics2D.minPenetrationForPenalty

    You're best to have your visuals (sprites etc) slightly larger than the colliders or have everything at a larger scale so that it is visually insignificant.
     
  8. modegames

    modegames

    Joined:
    Dec 1, 2014
    Posts:
    37
    Yes that's correct it's important that the physical size of things is realistic so if you correct the scale for world to pixel by your textures scale factor then you should not have to correct your penetration value.