Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

2D Box Collider Snags

Discussion in 'Physics' started by Alanisaac, Feb 8, 2015.

  1. Alanisaac

    Alanisaac

    Joined:
    Jan 25, 2015
    Posts:
    15
    I'm making a game that has square obstacles set up in a grid. Each obstacle is a square with a 2D box collider.

    My player is also a square of the same size, with a similar box collider. If two obstacles are next to each other, the player can get caught on the edges of the obstacle colliders. It will stay "snagged" there until moved in the opposite direction of the colliders.

    I've found multiple threads that say this can be addressed by using circle colliders rather than box colliders. But with my game, I'd like the visual shape of my sprite to actually be a box. If I make the collider a circle, the obstacles and my player can intersect, which looks funny.

    My question is: is there a clever way to use colliders in 2D that will prevent snags but act like a box collider in terms of the area of collision?
     
  2. Olipool

    Olipool

    Joined:
    Feb 8, 2015
    Posts:
    320
    Maybe you can post a picture of your player sprite? What you can try is to add very smal circle colliders in the corners of your box, just a pixel outside or so, have to try this. But by that you have your shape act like a box except for the problematic zones but there the difference should not be visible to the player