Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to know if there is any known solution for handling the player's movement on slopes using Box2D engine.

I tried to do it using a circle as the player. Everything was fine until I tried to walk on slopes, the main problem is that due to gravity, the circle does not stop on the slope.

Please if somebody has tried this before I'll appreciate it. If you have a better solution without the physics engine would be fine for me too.

Thank you.

share|improve this question
Try reducing the friction or rotational velocity of the player to zero. – tesselode Oct 16 '12 at 23:18
possible duplicate of Make player to always move along the terrain – Byte56 Oct 17 '12 at 0:32
@Byte56 The question you linked to is to prevent a hop at the top of the ramp. There isn't any overlap. – ClassicThunder Oct 17 '12 at 2:06
@ClassicThunder OK. They seemed pretty similar to me. It is only a possible duplicate after all :) – Byte56 Oct 17 '12 at 3:02
I'll try this too and will let you know the results, thanks. – songokuhd Oct 17 '12 at 14:09

Behind boxboy by Robert Dodd describes a very sensible method for making a character in box2d that plays like a more traditional platformer character.

The main components is the anglejoint as well as a fixed speed motor joint. With enough friction your character will not slide down slopes, and as long as the motor is active it would keep it from rolling downhill. I'm uncertain exactly how, but you should be able to keep the motor engaged even when its not rotating, to prevent the circle from rolling freely.

share|improve this answer
Thank you!, I'll try this and post my results back here for you to know. – songokuhd Oct 17 '12 at 14:05

You could raycast to judge whether the character is standing on a slope and modify their velocity accordingly.

share|improve this answer
Could you go into a little more detail on how and why this would work? – Anko Sep 1 '15 at 14:49
@Anko he would have to modify this one as well. :P – Alexandre Vaillancourt Sep 1 '15 at 14:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.