Search Unity

Materials = Player slides down a hill, or doesn't but gets stuck on platforms

Discussion in '2D' started by bloodwolftico, Sep 15, 2019.

  1. bloodwolftico

    bloodwolftico

    Joined:
    Nov 13, 2017
    Posts:
    100
    Hi. So in my 2D game, I've been playing around materials on both the player, the terrain (tilemap) or the enemies, with different degrees of success.

    I was ok on how the player was behaving before but now I want the feeling of the player moving around to be more consistent.

    My current problem is that if the player is on even ground, he doesn't move, which is fine. But if he stands on a slanted slope, he starts sliding down on it. Here are the 2 materials I've been testing:

    - Friction (0.1)
    - Slippery (no friction)

    If I don't add materials to the player, he stands still just fine. But will struggle to go up hills (as terrain is not even but has different physical shapes). And the worst part is that when jumping against a platform, if he hits the side and the player doesn't let go of the move key, he will just get stuck in the air, trying to move against it, and will never fall off.

    So what I did was add "Slippery" to the player, and this helps him navigate up slopes and prevents getting stuck on platforms.

    But if I do that, if he stands on sloped terrain, he will start sliding down. I understand physics will move his rigidbody down the slope, but I've tried to add friction to the ground to make it harder for this to happen, to no avail. It seems the player's no friction material overrides the ground.

    I just want to make it so the player doesn't get stuck to the platforms, but also doesn't just as easily roll down hills (I want some friction on the hills).

    Any ideas?
     
  2. Adien22

    Adien22

    Joined:
    Aug 19, 2019
    Posts:
    44
    This looks promising for what you need. Let me know if this helps