Hello how would i make my distance joint like a spring. While looking through the box2d docs and testbeds i found this code to create a distance joint and make it springy:
DistanceJointDef jd = new DistanceJointDef();
Vec2 p1, p2, d;
jd.FrequencyHz = 4.0f;
jd.DampingRatio = 0.5f;
jd.Body1 = ground;
jd.Body2 = _bodies[0];
jd.LocalAnchor1.Set(-10.0f, 10.0f);
jd.LocalAnchor2.Set(-0.5f, -0.5f);
p1 = jd.Body1.GetWorldPoint(jd.LocalAnchor1);
p2 = jd.Body2.GetWorldPoint(jd.LocalAnchor2);
d = p2 - p1;
jd.Length = d.Length();
_joints[0] = _world.CreateJoint(jd);
now heres my code for creating a distance joint:
//distance joint #1
myjoint.Initialize(ballBody, ball13Body, ballBody->GetPosition(), ball13Body->GetPosition());
myjoint.collideConnected = true;
JointA = (b2DistanceJoint*) _world->CreateJoint(&myjoint);
So ive tried putting the DampingRatio part in my code but it doesnt work. Heres how i tried:
myjoint.DampingRatio = 0.5f;
and i keep getting the error: 'struct b2DistanceJointDef' has no member named 'DampingRatio'
Does anyone know how i can make my distance joint springy?
-Nick Homme