Search Unity

Bug Getting stuck on a wall

Discussion in 'Physics' started by NintendoAsh12, Apr 30, 2023.

  1. NintendoAsh12

    NintendoAsh12

    Joined:
    Feb 15, 2021
    Posts:
    91
    when I am moving and I run and hit a wall but now if I keep pressing forward and I try to push jump I can't I have to move away from the wall to jump. all of the walls have slippy materials on them and I don't know what to try it could be my script but I won't post it here right now but if someone needs to look at it I can post it somewhere.
    here is a video of what is going on: https://clipchamp.com/watch/CHlT2HDkqrQ
     
  2. Mangonels

    Mangonels

    Joined:
    May 8, 2018
    Posts:
    20
    I solved this in my 3D game by setting up my player controlled game object with:

    - 1 capsule collider as an outer "frictionless skin" (highest capsule in image). This one has a physics material configured like this:
    upload_2023-5-6_21-3-44.png
    This collider acts as an extra layer for the higher parts of my character. These are the ones that are usually in contact with walls and ceiling, and the physics material with 0 Friction Combine set to Multiply makes it slip on them and not get stuck. So you don't really need to add the physics material to ALL your layout's colliders, just your player controlled character, or any other characters that may get stuck to walls.

    - 1 sphere collider (mid height sphere in image) as a feet or ground friction skin. No physics material attatched to it. Having it set up like this seems to provide some default friction with unity 3D's colliders when "walking on them" (should really be the same in 2D).

    - 1 trigger enter collider (lowest sphere in image) for grounded checking.

    Of course, your game is in 2D, and your character seems to be a square/box for now, but I'm still providing this setup as an example which may suit your needs. You could try to adapt this to 2D colliders, or, if your game is actually 3D seen in 2D, you could try to implement something more similar.
    upload_2023-5-6_21-0-42.png
    This is how it looks.

    There may be other/better solutions, even for my own case, but for now I'm quite happy with the result.

    It may suit your needs, hope it helps.