Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Sprite snagging

Discussion in '2D' started by Avo, Dec 1, 2013.

  1. Avo

    Avo

    Joined:
    Dec 4, 2010
    Posts:
    236
    I've currently set up a little 2d scene where I have a character who walks around on a bunch of boxcollider 2d's. They're all perfectly aligned and yet sometimes my character snag's on them. With a 3d game I'd increase the skin variable on the character controller to fix this but I'm unsure of how to fix this on a 2d character. Thanks for your time!
     
    Last edited: Dec 1, 2013
  2. unitylover

    unitylover

    Joined:
    Jul 6, 2013
    Posts:
    346
    What kind of collider are you using on the character?
     
  3. Gesh

    Gesh

    Joined:
    Feb 23, 2013
    Posts:
    6
    I also have this problem, I have 500 tiles aligned all 50x50 with a 32x32 player, when moving my character it randomly gets stuck on tiles like there's an invisible wall.. it's also completely random but happens fairly often.. when it happens I must slightly change direction and then I can continue going the direction I was going.

    All of the tiles are using a box collider and so is the player.
    *I enabled Fixed Angle on the character's rigidbody, with it disabled the character just flips all over the place as soon as it hits a snag.
     
  4. unitylover

    unitylover

    Joined:
    Jul 6, 2013
    Posts:
    346
    The best way to get around the snag (I think it's a Box2d issue) is to use a circle collider as the base of your player and a box for the top. I setup a quick scene myself and can verify this will eliminate your problem.

    $character-collider.png

    Edit: You may want to avoid intersecting colliders if you're using collision detection scripts so just make sure the circle doesn't go through the box collider and you're all set.
     
  5. Avo

    Avo

    Joined:
    Dec 4, 2010
    Posts:
    236
    Sorry for my late response Unity. I was indeed using only a box collider. I saw that they used a circle and a box collider in their demo but I thought that had to do with the shape of their character instead of moving around. Thank you for your help Unitylover.