This project has moved. For the latest updates, please go here.

A couple of questions about Pin Joints and Collisions

Mar 2, 2010 at 1:06 AM
Edited Mar 2, 2010 at 9:28 AM

Hi everyone,


I'm working on my Final Year Project at University to make a program where physical objects can balance on their own.

So far, it's going well :) I had a couple of questions though, and if anyone could point me in the right direction I'd be very appreciative.

1) I'm making a ragdoll using pinjoints to attach each body part together.  I'm having a bit of trouble with this though.  Each joint I attach end up having a large gap between each anchor.

For example, when attaching the Leg to the Torso, there is a large gap between the leg and the torso, becoming larger when the leg or torso rotates.

Here's a snippet of some of the code for my PinJoints.

PinJoint leftLegTorso = JointFactory.Instance.CreatePinJoint(simulator, leftLegBody, leftLegAnchor, torsoBody, torsoAnchor1);
PinJoint rightLegTorso = JointFactory.Instance.CreatePinJoint(simulator, rightLegBody, rightLegAnchor, torsoBody, torsoAnchor2);
leftLegTorso.TargetDistance = 0;
rightLegTorso.TargetDistance = 0;
LinearSpring leftLegTorsoSpring = SpringFactory.Instance.CreateLinearSpring(simulator, leftLegBody, leftLegAnchor, torsoBody, torso1, 1000, 0);
LinearSpring rightLegTorsoSpring = SpringFactory.Instance.CreateLinearSpring(simulator, rightLegBody, rightLegAnchor, torsoBody, torso2, 1000, 0);

I've had a play around with the TargetDistance values but I get the same result.  As you can see, I've had a go at using Springs to pull the two bodies together but I'm still getting the same problem.

Is this just the general behaviour of PinJoints or do I need to add something else to keep the legs fixed to the torso?  I noticed in the Simple Samples ragdoll it uses PinJoints too.  If anyone's confused by what I mean I can happily add a screenshot if you need it. =)


2) EDIT: I've just found out how to do this using CollisionGroups! I just added both legs and feet to the same CollisionGroup and this works perfectly =) I'm thinking about allowing the legs of the ragdoll to move into each other without collision, as if the legs were moving behind the other.  Is there a way I can ignore collision detection for the legs (leftLegGeom and rightLegGeom I would assume) but still have them collide with other Geoms?



If I haven't explained myself very well please just say and I'll have another go! I'm still fairly new to Farseer =)

Thanks very much for your help.  


Mar 4, 2010 at 12:58 PM
Edited Mar 4, 2010 at 12:59 PM

Hi Folks,

I've been playing about with the PinJoints, but I'm still quite stumped about this.  I've included a screenshot of my ragdoll character so far so you can see what I mean:


It's just the torso, legs and feet at the moment.  You can see here the gaps between the each joint.  Am I perhaps using the wrong type of joint altogether?

Any tips would be great!  =)


Thanks everyone,