Hey guys!
I'm trying to make a ragdoll with Spine and Box2D, the way it should work is when an entity dies it creates a Box2D body from Spine attachments, joins them together with joints (this part is already working), then I'd like to let Box2D take control of the physics and the created bodies should move the appropriate spine bones with them.
The problem is I can't get to bones in the correct positions (x, y, rotation).
This is how I'm currently trying it:
for (Slot slot : skeleton.getSlots()) {
if (!(slot.getAttachment() instanceof Box2dAttachment)) continue;
Box2dAttachment attachment = (Box2dAttachment)slot.getAttachment();
if (attachment.body == null) continue;
Body body = attachment.body;
float x = body.getWorldCenter().x*PPM - skeleton.getX();
float y = body.getWorldCenter().y*PPM - skeleton.getY();
float rotation = body.getAngle();
slot.getBone().setPosition(x, y);
slot.getBone().setRotation(rotation);
}