Can you have two grab constraints on a ragdoll?

Oct 9, 2010 at 11:13 PM

Can you have two grab constraints on a ragdoll?  For example, right now, I have a grab constraint on the head and left hand... and the model just starts spinning and flying out of control.

Cheers.

Coordinator
Oct 13, 2010 at 2:18 AM

Grab constraints are really meant for mouse picking, so I didn't do any kind of testing using more than one at the same time. You might try using a WorldPointContraint and see if that's any better. Too many constraints in opposition can cause some really bad instability, though.

Oct 13, 2010 at 6:01 PM

Yes, I swapped over to WorldPointConstraints the day I asked question :-P.

Alright, new suggestion: I think you should add the ability to hold a particular point within the body with your WorldPointConstraint, besides just the body's origin.  I think this is easy to add:

 

public WorldPointConstraint(RigidBody body, Vector3 worldPoint)
	: base(body, body)
{
	_worldPoint = worldPoint;
	Vector3.Transform(ref worldPoint, ref BodyA.WorldInverse.Combined, out _bodyPoint);
}

To something like...

 

public CWorldPointConstraint(RigidBody body, Vector3 worldPoint, Vector3 bodyPoint)
	: base(body, body)
{
	_worldPoint = worldPoint;   
    Vector3.Transform(ref bodyPoint, ref BodyA.WorldInverse.Combined, out _bodyPoint);
}

Is that correct?

Cheers.

Coordinator
Oct 13, 2010 at 8:02 PM

Actually, if I recall correctly, the origin is only used if it happens to be exactly at the specified world point. If you want to use the corner of a cube as the constraint point, just move the corner to the specified world point first, and then apply the constraint. The corner should then be attached to the world point instead of the center.

The constraints generally assume that you've already moved the object into a position that satisfies the constraint when they're created.