Horizontally flipping/mirroring bodies with joints

Topics: User Forum
Jul 12, 2011 at 8:19 PM

I have read the previous discussions on horizontally flipping bodies. I first tried scaling the fixtures inside the active body with Vector2(-1,1). Using the DebugView I saw the fixtures drawn flipped but the collision used the non-scaled fixtures.  So I decided to implement the recommended solution of creating multiple bodies and enabling them depending on which direction the player is facing. To synchronize the bodies I first tried using a weld joint but the inactive body didn't follow the active body; understandable, since it was removed from the update list. So instead I copy the important information between the bodies and it works fine. Flipping bodies horizontally isn't the problem.

The problem comes when I try to join other bodies using joints, such as a sword or dangling chain. Since the joint position and body it's joined to changes depending on the active body, it seems the solution would be to duplicate those bodies and copy the important information between them, just like the main body. This really gets messy fast so my question is if there is a better way to horizontally flip bodies and preserve joints they are attached to?

Developer
Jul 12, 2011 at 11:44 PM

Probably best to rebuild the entire objects structure when flipping. There is no method of flipping an object with joints, much less an object without joints. This does seem like it would be a good addition to the engine.