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

Imagine I have a skeleton — that is a set of bodies held together through various constraints and joints — and I want to flip it. Bodies cannot be flipped in Box2D, so how can I fake that?

Here's an example: I have a humanoid skeleton, made out of different Box2D bodies: the head, torso, upper arm, lower leg, etc. These Box2D bodies are held together by joints. Some of the joints have angle constraints, like the ones between the upper and lower arm, which do not allow the 'elbow' to twist unnaturally.

When I turn my character the other way around, I should flip the skeleton and its joints should be flipped as well. How can I achieve that in Box2D?

share|improve this question
Would you clarify to us what is the "pose" of the skeleton? That is important, but im assuming its facing right and you just want to make it look the other way? I can't right now tell you exactly, but what should work is using the same code you used to generate the skeleton, and flip the x coordinates between each others. – Grimshaw Mar 6 '12 at 13:45
@DevilWithin Yes, I meant flipping it from facing right to facing left. Obviously, what you described is how you would implement the algorithm for finding the flipped position, but are there any quirks related to Box2D that you need to be careful about? – Paul Manta Mar 6 '12 at 13:50

At the risk of being a hypocrite, because I hate it when people start an answer to a question with: "I don't know/use/(etc.) (insert object of question) but I think..."

I don't know Box2D (but I'm learning!), but couldn't you just create two skeletons that are mirror images and switch between them when needed?

share|improve this answer
That's one option. But I don't know how well it will work (how fast is it? will the system behave unexpectedly in certain situations?) so I asked here first. – Paul Manta Mar 6 '12 at 13:48
This was going to be my answer. Create two complete sets of box2d bodies, and switch between them. Box2d lets you disable bodies without destroying them or removing them from the simulation, so speed shouldn't be an issue. Your biggest issue will be the character appearing to 'teleport' from one orientation to the other, which may cause some instability in the physics simulation if the new position intersects with something. I'd expect it to be minor, though. – Blecki Mar 6 '12 at 14:02

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.