Let's say I'm trying to create a ninja lowering himself down a rope, or pulling himself back up, all whilst he might be swinging from side to side or hit by objects. Basically like http://ninja.frozenfractal.com/ but with Box2D instead of hacky JavaScript.

Ideally I would like to use a rope joint in Box2D that allows me to change the length after construction. The standard Box2D RopeJoint doesn't offer that functionality.

I've considered a PulleyJoint, connecting the other end of the "pulley" to an invisible kinematic body that I can control to change the length, but PulleyJoint is more like a rod than a rope: it constrains maximum length, but unlike RopeJoint it constrains the minimum as well.

Re-creating a RopeJoint every frame using a new length is rather inefficient, and I'm not even sure it would work properly in the simulation.

I could create a "chain" of bodies connected by RotationJoints but that is also less efficient, and less robust. I also wouldn't be able to change the length arbitrarily, but only by adding and removing a whole number of links, and it's not obvious how I would connect the remainder without violating existing joints.

This sounds like something that should be straightforward to do. Am I overlooking something?

Update: I don't care whether the rope is "deformable", i.e. whether it actually behaves like a rope, or whether it collides with other geometry. Just a straight rope will do. I can do graphical gimmicks while rendering; they don't need to exist inside the physics engine. I just want something a RopeJoint whose length I can change at will.

  • \$\begingroup\$ possible duplicate of How do I make a rope from point A to B in Box2D? \$\endgroup\$
    – House
    Oct 16, 2012 at 22:38
  • \$\begingroup\$ I'm not so sure that rope in the demo you showed is a physics object. It looked like it wasn't colliding with the character or the cave walls. Could just use a spline. \$\endgroup\$
    – House
    Oct 16, 2012 at 22:39
  • \$\begingroup\$ I use Box2D quite a bit and have no idea how to achieve this and doubt that its possible. \$\endgroup\$ Oct 17, 2012 at 2:08
  • \$\begingroup\$ @Byte56: Not a dupe. The "extensible" bit is what is different. Also, I don't care if my rope is straight; I can add some fancy animation on top of that. \$\endgroup\$
    – Thomas
    Oct 17, 2012 at 12:39
  • 1
    \$\begingroup\$ If you really want a "deformable" rope, I'll put my previous comment on an answer. \$\endgroup\$
    – fableal
    Oct 17, 2012 at 13:23

2 Answers 2


If you want a "deformable" rope, that isn't possible in box2d, as box2d is a rigid body physics engine; check soft body dynamics, I would sugest the Bullet library.

A "simpler" solution using box2d would be to "emulate" the variation of length by hiding some of the rope (with fixed length) outside the visible world / not drawing some of the rope.


This would work like pulling the top extremity (b) of the rope (c) up/downwards. I would add some static objects (a) so that the ninja doesn't escape the visible world for too long...

  • \$\begingroup\$ Sorry, it seems my description still isn't clear. I don't care whether the rope is deformable; softbodies are overkill especially since I'm targeting a mobile platform. \$\endgroup\$
    – Thomas
    Oct 17, 2012 at 18:42
  • \$\begingroup\$ Your other idea is interesting, but I don't quite see how I would set this up using rigid bodies and joints. I could use a stick to simulate the rope, but it would constrain the distance between the ninja and attachment point to be constant, whereas I just want to constrain it to a maximum. \$\endgroup\$
    – Thomas
    Oct 17, 2012 at 18:43
  • \$\begingroup\$ I added the "deformable" only for completeness (you said you "didn't care", not that "didn't want" :P) \$\endgroup\$
    – fableal
    Oct 17, 2012 at 19:31

Ok, I naively assumed that LibGDX wrapped all of Box2D, so this would be purely a Box2D problem.

It turns out that vanilla Box2D, at least in trunk, has a function called b2RopeJoint::SetMaxLength. I've added it and got a pull request merged within minutes. It is now available (and working) in LibGDX nightlies.


You must log in to answer this question.

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