Trigger with Spring

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Phippu
Posts: 24
Joined: Fri Jun 03, 2011 3:39 pm

Trigger with Spring

Post by Phippu »

Hi Norbo

I try to implement a button/trigger that lies on the bottom and has a spring. The button should be pressed when an heavy object falls on it and should be released if the object gets removed. I started with a box and a PrismaticJoint, so that the box (button) can move only up and down. So what I need now is a spring or something like that, but I could not find a useful Joint. How do I get that?

Thank you!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Trigger with Spring

Post by Norbo »

Using the PrismaticJoint's LinearAxisMotor is one option:
var trigger = new Box(new Vector3(0, 3, 5), 2, 1, 2, 30);
var prismaticJoint = new PrismaticJoint(null, trigger, new Vector3(0, 0, 5), Vector3.UnitY, trigger.Position);
//Activate the combo-joint's LinearAxisMotor and set it to servo mode so it strives for a target.
prismaticJoint.Motor.IsActive = true;
prismaticJoint.Motor.Settings.Mode = MotorMode.Servomechanism;
prismaticJoint.Motor.Settings.Servo.Goal = 3;
//Weaken the spring.
prismaticJoint.Motor.Settings.Servo.SpringSettings.StiffnessConstant /= 500;
prismaticJoint.Motor.Settings.Servo.SpringSettings.DampingConstant /= 500;
Phippu
Posts: 24
Joined: Fri Jun 03, 2011 3:39 pm

Re: Trigger with Spring

Post by Phippu »

Great, thank you! You deserve definitifely a donation when my project gets released 8)
Post Reply