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.

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

2 Answers 2


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.

  • \$\begingroup\$ Thank you!, I'll try this and post my results back here for you to know. \$\endgroup\$
    – songokuhd
    Commented Oct 17, 2012 at 14:05

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

  • \$\begingroup\$ Could you go into a little more detail on how and why this would work? \$\endgroup\$
    – Anko
    Commented Sep 1, 2015 at 14:49
  • 1
    \$\begingroup\$ @Anko he would have to modify this one as well. :P \$\endgroup\$
    – Vaillancourt
    Commented Sep 1, 2015 at 14:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .