Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have created a ragdoll for my game but the problem I found was that the ragdoll joints are not perfectly implemented so they are continuously moving. Ragdoll does not stand at fix place. I here paste my work for that and suggest some guidance about that so that it can stand on fix place.

    chest = new Chest(pX, pY, gameObject.getmChestTextureRegion(),
            gameObject);

    head = new Head(pX, pY - 16, gameObject.getmHeadTextureRegion(),
            gameObject);

    leftHand = new Hand(pX - 6, pY + 6, gameObject.getmHandTextureRegion()
            .clone(), gameObject);
    rightHand = new Hand(pX + 12, pY + 6, gameObject
            .getmHandTextureRegion().clone(), gameObject);
    rightHand.setFlippedHorizontal(true);
    leftLeg = new Leg(pX, pY + 18, gameObject.getmLegTextureRegion()
            .clone(), gameObject);
    rightLeg = new Leg(pX + 7, pY + 18, gameObject.getmLegTextureRegion()
            .clone(), gameObject);
    rightLeg.setFlippedHorizontal(true);

    gameObject.getmScene().registerTouchArea(chest);
    gameObject.getmScene().attachChild(chest);

    gameObject.getmScene().registerTouchArea(head);
    gameObject.getmScene().attachChild(head);

    gameObject.getmScene().registerTouchArea(leftHand);
    gameObject.getmScene().attachChild(leftHand);

    gameObject.getmScene().registerTouchArea(rightHand);
    gameObject.getmScene().attachChild(rightHand);

    gameObject.getmScene().registerTouchArea(leftLeg);
    gameObject.getmScene().attachChild(leftLeg);

    gameObject.getmScene().registerTouchArea(rightLeg);
    gameObject.getmScene().attachChild(rightLeg);

    // head revolute joint
    revoluteJointDef = new RevoluteJointDef();
    revoluteJointDef.enableLimit = true;

    revoluteJointDef.initialize(head.getHeadBody(), chest.getChestBody(),
            chest.getChestBody().getWorldCenter());

    revoluteJointDef.localAnchorA.set(0f, 0f);
    revoluteJointDef.localAnchorB.set(0f, -0.5f);

    revoluteJointDef.lowerAngle = (float) (0f / (180 / Math.PI));
    revoluteJointDef.upperAngle = (float) (0f / (180 / Math.PI));
    headRevoluteJoint = (RevoluteJoint) gameObject.getmPhysicsWorld()
            .createJoint(revoluteJointDef);

    //
    // left leg revolute joint

    revoluteJointDef.initialize(leftLeg.getLegBody(), chest.getChestBody(),
            chest.getChestBody().getWorldCenter());
    revoluteJointDef.localAnchorA.set(0f, 0f);
    revoluteJointDef.localAnchorB.set(-0.15f, 0.75f);
    revoluteJointDef.lowerAngle = (float) (0f / (180 / Math.PI));
    revoluteJointDef.upperAngle = (float) (0f / (180 / Math.PI));

    leftLegRevoluteJoint = (RevoluteJoint) gameObject.getmPhysicsWorld()
            .createJoint(revoluteJointDef);

    // right leg revolute joint
    revoluteJointDef.initialize(rightLeg.getLegBody(),
            chest.getChestBody(), chest.getChestBody().getWorldCenter());
    revoluteJointDef.localAnchorA.set(0f, 0f);
    revoluteJointDef.localAnchorB.set(0.15f, 0.75f);
    revoluteJointDef.lowerAngle = (float) (0f / (180 / Math.PI));
    revoluteJointDef.upperAngle = (float) (0f / (180 / Math.PI));
    rightLegRevoluteJoint = (RevoluteJoint) gameObject.getmPhysicsWorld()
            .createJoint(revoluteJointDef);

    // left hand revolute joint
    revoluteJointDef.initialize(leftHand.getHandBody(),
            chest.getChestBody(), chest.getChestBody().getWorldCenter());

    revoluteJointDef.localAnchorA.set(0f, 0f);
    revoluteJointDef.localAnchorB.set(-0.25f, 0.1f);

    revoluteJointDef.lowerAngle = (float) (0f / (180 / Math.PI));
    revoluteJointDef.upperAngle = (float) (0f / (180 / Math.PI));
    leftHandRevoluteJoint = (RevoluteJoint) gameObject.getmPhysicsWorld()
            .createJoint(revoluteJointDef);

    // right hand revolute joint
    revoluteJointDef.initialize(rightHand.getHandBody(),
            chest.getChestBody(), chest.getChestBody().getWorldCenter());

    revoluteJointDef.localAnchorA.set(0f, 0f);
    revoluteJointDef.localAnchorB.set(0.25f, 0.1f);
    revoluteJointDef.lowerAngle = (float) (0f / (180 / Math.PI));
    revoluteJointDef.upperAngle = (float) (0f / (180 / Math.PI));
    rightHandRevoluteJoint = (RevoluteJoint) gameObject.getmPhysicsWorld()
            .createJoint(revoluteJointDef);
share|improve this question
    
I conclude after experimenting that earth gravity was affecting for the continuous movement of the ragdoll –  Siddharth May 30 '12 at 13:24
add comment

2 Answers

up vote 4 down vote accepted

Luckily, I found the solution of my problem and here I post the answer for other community member to help them. I set Mask Bit for each part of the body like leg,hand,chest,head. So that they don't collide with each other. As a result the continuous movement of the ragdoll was stop.

share|improve this answer
1  
+1 Nice detective work. –  Patrick Hughes Jun 1 '12 at 17:48
add comment

Well i dont think it's the joint implementation,it's just that ragdolls can't help ,but move when running a physics simulation ,because there's say gravity affecting the parts and joints and now counter force applied to keep them straight.If you just want to keep the ragdoll straight you could limit the joint angles or apply some balancing strategy.

share|improve this answer
add comment

Your Answer

 
discard

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.