2D Platformer : Player Sticking to Walls Even With 0 Friction

Updated on July 30, 2014 in [A] 2D
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
12 on July 28, 2014

I came across the same problem while making my own platformer type game that was seen in the 2D platformer tutorial videos where the player sticks to the side of platformers when the player falls of them. I have applied a 2d physics material with 0 friction to both my player characters and the platforms and the player still sticks to the side of the platform. Is there something else that I need to do?

  • Liked by
Reply
0 on July 28, 2014

I would recommend overriding unity physics. So you would just use the colliders as triggers and set the rigidbodies to kinematic, and apply forces manually. For platforming games that require specific behaviours, default physics is bad.

  • Liked by
Reply
Cancel
0 on July 29, 2014

I’m not quite sure how to do that.

  • Liked by
Reply
Cancel
0 on July 29, 2014

Can you post pictures of how your characters are ‘sticking’ to the platforms?

  • Liked by
Reply
Cancel
0 on July 29, 2014

It only happens when you walk/jump off the platform and then touch the side of the platform (in this case move back to the right while in the air to touch the left side of the platform). You don’t need to hold right once you have touched the wall and are stuck, but it stays there until you press left.

Edit: picture isn’t showing so here is a link. https://www.dropbox.com/s/ma03lh1szp8mra5/sticking.png

  • Liked by
Reply
Cancel
1 on July 29, 2014

I just added a slippery physics material to objects that the player would collide with. (Walls, Platforms, etc). There’s a prefab slippery material in the 2D Sample Assets.

on July 29, 2014

Wouldn’t this make the player also slide around when walking on top of the platform?

Show more replies
  • Liked by
Reply
Cancel
0 on July 29, 2014

Create physics material with 0 friction
Apply box collider or edge or polygon to whatever object u need
Drag material to box collider..
I had this exact problem, and its fixed now, trust me it works !

  • Liked by
Reply
Cancel
4 on July 29, 2014

I came across this issue as well and applying the Physic’s material with 0 works but you also have to watch the size of your colliders on the player object.  I had a circle collider on the feet of the player and a box on the torso of the player.  The collider on the torso was larger across than the circle so it caused the box collider to sit on top of the platform causing the player to hang there even through the physics material was set to 0.

on July 29, 2014

I only have one box collider on the player. Is there a chance that somehow the bottom of the collider is somehow sitting on the side of the platform collider?

Helpful
on July 29, 2014

Perhaps, when you have the game running in Unity get your character “hung” on the object, click on your Scene view, click on your player and zoom in and see if you can see if the collider is hanging on the other collider.

on July 30, 2014

THANK YOU!!!! It was a very stupid issue. You see, I wanted the top of my player objects to count as ground so that double jump will be reset just as if you had landed on a platform. To achieve this I made a thin invisible rectangle that rest above the player’s head. After switching to scene view during play I saw that the rectangle was extending past the edge of the player box collider and was resting on the top of the platform as if a hand had reached up to grab the edge. 

https://www.dropbox.com/s/e7yvw3lshs7oomy/holdingOn.png

Helpful
on July 30, 2014

Cool, glad to have helped!

Show more replies
  • Liked by
Reply
Cancel