Search Unity

2D character collider issues with edges

Discussion in '2D' started by ppowersteef, Feb 9, 2016.

  1. ppowersteef

    ppowersteef

    Joined:
    Jan 24, 2016
    Posts:
    8
    I'm not sure if this is is fitting for "2D" or "psygics". I hope it's okay.

    Hello reader,

    I'm pretty new to Unity and I'm making a simple 2D shooter, though I've a big issue with the collider.
    At first, It seems to either slip away over the ground of becoming stuck on the wall.

    I use Materials to solve this issue a bit, Using two different-sized 2D circle colliders,
    one supposed to slip from the wall, and one to keep friction on the ground.
    upload_2016-2-9_15-46-56.png <Circle below is to not slip from the ground, the one above is to slip from walls, I made it bigger so the circle with friction wouldn't touch the walls.
    upload_2016-2-9_15-46-25.png
    "Good friction" has a friction of 1.
    "Slippery" has no values.

    Yet, I'm now only having a problem with the edges of a block, because that will be seen by the circle with friction.
    Collision needed.gif


    Maybe I'm thinking too hard about it, it sounds like it shouldn't be hard to be fixed, but yet, I don't know how it should be. I was thinking about the sides of a box collider to have a different material, if that was possible.

    I thank you for reading this, and I would greatly like it if you'll reply with a possible answer :)
     
  2. Hyblademin

    Hyblademin

    Joined:
    Oct 14, 2013
    Posts:
    725
    It seems like a somewhat common solution to make the upper, low-friction collider a box that covers most of the character, and the lower, high-friction collider just barely stick out of the bottom. The downside to this arrangement is that it doesn't play nice with slopes.

    An approximation:

    upload_2016-2-9_15-46-56.png

    Do you think this could work for your project?
     
    ppowersteef likes this.
  3. ppowersteef

    ppowersteef

    Joined:
    Jan 24, 2016
    Posts:
    8
    that might work, I'll try it the next time.

    Thank you
     
  4. ppowersteef

    ppowersteef

    Joined:
    Jan 24, 2016
    Posts:
    8
    It seems to have worked out,

    It thought it would be stuck at one of the box colliders below, but that's not the case here,
    I don't have to worry about slopes, I just make sure they won't appear then, at least in the current state then.

    Once again, thank you for helping out