playMaker

Author Topic: Player stuck on wall when jumping (2d game).  (Read 4974 times)

Asvarox

  • Playmaker Newbie
  • *
  • Posts: 3
Player stuck on wall when jumping (2d game).
« on: July 20, 2016, 03:07:05 PM »
Hello!
I have a problem with player controller. I adding a velocity on X axis for player to move, and add force 2d to jump. When i move and jumping at same time i can climb on coliders. How can i solve that problem? It should fall to the ground not stuck in air. Oh i forgot say that i have a rigidbody 2d on player.

I know that my english suck, but i'm trying as i can.

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: Player stuck on wall when jumping (2d game).
« Reply #1 on: July 20, 2016, 04:06:11 PM »
Hi and welcome to the forum!

I'm not exactly sure what you mean, so sorry for assuming :) .

When you say 'player stuck on wall', do you mean that when you jump and you hit a side of the wall, you don't slide down the wall?

If so you can try to add a physics material to the wall's collider:

https://docs.unity3d.com/Manual/class-PhysicsMaterial2D.html

In the project window just click create and chose 'physics material 2d'. Then set the friction to very low and drag that onto the collider, into the 'physics material' slot. This should make it so that when you hit the wall, you slide down it. (Also if you're making a platformer, I'm sure you will have fun with the bounciness setting :D ).

Good luck with it, hope this helps!

(Edit to add: as you're making a 2d plartformer, you should check out this tutorial, if you have not come across it already that is: https://youtu.be/2TmsuoBlfcQ )
« Last Edit: July 20, 2016, 04:09:34 PM by Zeldag »

Asvarox

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Player stuck on wall when jumping (2d game).
« Reply #2 on: July 20, 2016, 04:40:01 PM »
Quote
When you say 'player stuck on wall', do you mean that when you jump and you hit a side of the wall, you don't slide down the wall?
That is it!

I added bounciness material to colliders as you say but its not resolve a problem.
Its all okey when i stop pressing a move key then Player falls down, but when i holding it then character dont slide down.

I keep watching tutorials on youtube, but i cant resolve that problem above. I know that is a easy way to resolve that. Maybe i should sleep on it and then i found solution.

Zeldag

  • Full Member
  • ***
  • Posts: 198
Re: Player stuck on wall when jumping (2d game).
« Reply #3 on: July 20, 2016, 05:49:49 PM »
Hi,

Dont necessarily need to add bounciness, did you try to reduce the friction to near 0?

If it does not work, maybe you need to add this material to the character too... (Ive never tried this in 2d, so sorry if this does not work - it solved the same issue for me in 3d).

« Last Edit: July 20, 2016, 05:51:43 PM by Zeldag »

Asvarox

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Player stuck on wall when jumping (2d game).
« Reply #4 on: July 21, 2016, 11:28:56 AM »
Quote
did you try to reduce the friction to near 0?

Thanks for help! If i adjust a Friction to 0.0 its working fine!