Problems with Mario-like ladders

Hello everyone !

I am trying to make a Mario-like platform game using Box2D for the physics and SFML for rendering. Everything went well until i wanted to put ladders in my map.

Basically, I want a ladder to be a non-colliding element, but which still lets me know when a mob is touching it so that I can allow him to climb. Therefore, I declared ladders as sensors. When a mob is climbing a ladder, he can go up, down, left or right and still can jump.

I browsed this forum for answers but I found nothing satisfying all my needs :

- setting zero-gravity makes my mob impossible to stop, and that includes slipping on the ground as he passes through the ladder
- if I understood joints well, I can't use this solution if I want my mob to be able to move left and right while climbing

If someone has a solution, please let me know asap !

Thanks !
A friction joint might be something to try. This would still allow the player to be knocked off the ladder by a strong impact though, not sure if you want that.
Thanks for your answer, so far I didn't find lots of information about this type of joint, but I will give it a try.

Otherwise, I finally managed to simulate the behaviour I want :
- I added body->SetGravityScale(0) and body->SetLinearDamping(10.0f) in my climb fuction : now my climbing character does not fall and can move in any direction, but thanks to the damping his movements stop when no moving action is performed
- on the contrary, I added body->SetGravityScale(1) and body->SetLinearDamping(0) to bring my character back a normal behaviour when he stops touching a ladder (ContactListener.EndContact) or when he jumps from a ladde

I'm still open to other ideas or examples using a friction joint. And I hope my solution can maybe help someone ^^
That sounds like a good solution. I think it would behave similar to a friction joint, but it's easier to implement. 🙂

Original thread: https://box2d.org/forum/viewtopic.php?t=8484