Search code examples
javabox2djbox2d

Best method for changing collision polygons in Box2d?


I'm wondering what I should do for my player character. Currently he has the idle stance, with all the collision polygons created etc. But I want him to move his arm polygon when he is punching. How would I do this? I have all the polygons statically coded in the game.

I'm coding in Java, but the code can be translated.


Solution

  • You should create his arms as two new bodies and connect them to the character body using a revolute joint (per arm). And when he punches, enable the motor of the joint to make the arm move up.