RevoluteJoint and angle problem

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

RevoluteJoint and angle problem

Postby Samos » Wed Mar 14, 2018 6:18 pm

I'm creating "rope" using many Bodies. All bodies are Dynamic, and are conected by RevoluteJoint (first with second, second with third etc.). First element id Kinematic (gravity can't affecton it). All joint have lower and upper angle set to 1 degree (in radians). Rope should be almost inflexible. But is flexible. Set angles to 0 don't solve problem. This should works like metal chain, not like rope. What is wrong with my code? Moreover, first and last rope's element is joined by RopeJoint

Code: Select all
Body lastBody = pointBody;
for (Body ropeBody : ropeBodies) {
            RevoluteJointDef jDef = new RevoluteJointDef();
            jDef.bodyA = lastBody;
            jDef.bodyB = ropeBody;
            jDef.lowerAngle = -(float) Math.toRadians(1);
            jDef.upperAngle = (float) Math.toRadians(1);
            jDef.enableLimit = true;
            jDef.collideConnected = false;

            jDef.localAnchorA.set(lastBody.getLocalCenter().x, lastBody.getLocalCenter().y - ROPE_HALF_HEIGHT);
            jDef.localAnchorB.set(ropeBody.getLocalCenter().x, ropeBody.getLocalCenter().y + (1f * ROPE_HALF_HEIGHT));


            lastBody = ropeBody;
rope.png (1.86 KiB) Viewed 173 times
Posts: 3
Joined: Sat Feb 17, 2018 11:00 am

Return to Libgdx Contributions

Who is online

Users browsing this forum: No registered users and 3 guests