Smoothing out sudden changes in velocity with a LinearMotor?
Posted: Fri Jul 06, 2012 11:02 pm
I can pick up and shake objects using a linear motor. The settings for the motor depend on the mass of the entity in order to keep the response the same across varying masses.
To shaking the entity I use the current position of the mouse each frame
The problem is that if I shake the mouse side to side very quickly then it produces unstable violent changes in the entity's velocity.
How could I reduce the force exerted onto the entity without affecting the strength of the motor?
I have considered interpolating between mouse positions and setting the goal position using the interpolated values but I think this might look a little sluggish.
Code: Select all
linearMotor.Settings.Servo.SpringSettings.StiffnessConstant = 60000f * Entity.Mass;
linearMotor.Settings.Servo.SpringSettings.DampingConstant = 900f * Entity.Mass;
linearMotor.Settings.MaximumForce = 10000f * Entity.Mass;
Code: Select all
var cursorRay = cursor.Ray;
Vector3 goalPosition = grabSpring.GoalPosition;
Vector3 position = cursorRay.Origin + cursorRay.Direction * grabDistance;
grabSpring.GoalPosition = goalPosition;
How could I reduce the force exerted onto the entity without affecting the strength of the motor?
I have considered interpolating between mouse positions and setting the goal position using the interpolated values but I think this might look a little sluggish.