Joints

Jun 27, 2008 at 4:02 PM
I think I'm trying to do something pretty straight forward but I've been spinning my wheels on it.

I would like to have a joint between two bodies that has a target angle and springs back to that target angle whenever a collision causes it to move away from the target angle. Much like the AngularSpringLever's used in the "Linear and Angular Springs" Farseer demo, except I don't want them Fixed - instead I want them tied to free bodies.

So I am using a RevoluteJoint and AngleSpring like below. But the end effect is that the joint is very loose (there is no spring to get the joint back to the original angle). I've tried different SpringConstant and DampningConstant values but I just can't get the effect of a restricted joint.

Am I totally off base here, or am I just missing the setting of some required attributes?

 

RevoluteJoint revoluteJoint;

 

 

AngleSpring angleSpring;

 

 

 

Vector2 ptCollisionCenter = // this is defined as a valid joint position;

 

revoluteJoint =

JointFactory.Instance.CreateRevoluteJoint(physicsSimulator, part1.BodyObject, part2.BodyObject, ptCollisionCenter);

 

angleSpring =

new AngleSpring(part1.BodyObject, part2.BodyObject, 1000000, 5000);

 

angleSpring.SpringConstant = 1000000;

angleSpring.DampningConstant = 5000;

angleSpring.TargetAngle = 0;

Jun 28, 2008 at 8:19 PM
Doh... Really stupid mistake... It helps when I remember to add the AngleSpring to the physics simulator :(

physicsSimulator.Add(angleSpring);