Page 1 of 1

### Simple body hanging in two ropes

Posted: Tue Jan 20, 2015 4:26 pm
I am trying to create a simple body hanging in two ropes. I have tried both ChipmunkPivotJoint, ChipmunkPinJoint and ChipmunkDampedSpring but it doesn´t work. I would really appreciate some input about what I am doing wrong.

Pseudo code
Code: Select all
`   ChipmunkBody *newBody = [ChipmunkBody bodyWithMass:10.0f andMoment:cpMomentForBox(10.0f, width, height)];   newBody.position =  startPointArg;        // Create the joints (assumes default center of mass in the middle)   CGPoint jointPos1 = CGPointMake(newBody.position.x - width*0.45f, newBody.position.y + ropeLength);   CGPoint jointPos1_2 = CGPointMake(newBody.position.x - width*0.45f, newBody.position.y);   CGPoint jointPos2 = CGPointMake(newBody.position.x + width*0.45f, newBody.position.y + ropeLength);   CGPoint jointPos2_2 = CGPointMake(newBody.position.x + width*0.45f, newBody.position.y);      self.joint1 = [ChipmunkPinJoint pinJointWithBodyA:[ChipmunkBody staticBody] bodyB:newBody anchorA:jointPos1 anchorB: jointPos1_2];   self.joint1.maxForce = INFINITY; self.joint1.maxBias = INFINITY;      self.joint2 = [ChipmunkPinJoint pinJointWithBodyA:[ChipmunkBody staticBody] bodyB:newBody anchorA:jointPos2 anchorB: jointPos2_2];   self.joint2.maxForce = INFINITY; self.joint2.maxBias = INFINITY;   // Add joints and body to space etc.`

### Re: Simple body hanging in two ropes

Posted: Thu Jan 22, 2015 3:25 pm
Looks like a bug calculating the distance between the points for the joints.

I calculate the distance to double check with this formula:
float distance = abs(ccpDistance(jointPos1, jointPos1_2));

distance = ropeLength OK!

When I check the calculated distance:
joint1.dist = 518.0f which is outside the screen!

If I use the set method it doesn´t effect the distance between the joints.