If I check the value of the Entity's LinearMomentum then it is: (0, -0.16454, 0)
This is especially noticeable if the Entity.IsActive is false.
Here is a video demostrating what I mean (notice the values at the right hand side): http://www.youtube.com/watch?v=JkDGnnCov-c
Here's my extended Setup method for a MotorizedGrabSpring class:
Code: Select all
public void Setup(Entity e, Vector3 grabLocation)
{
Entity = e;
// Get the original entity properties that will need to be changed for this GrabSpring to function correctly
isActive = Entity.IsActive;
isAffectedByGravity = Entity.IsAffectedByGravity;
isEntityDynamic = Entity.IsDynamic;
originalEntityCollisonRule = Entity.CollisionInformation.CollisionRules.Personal;
// Now change those properties so that the entity can be manipulated by the 'GrabSpring' in the desired manner
// Make sure that the grabbed entity is active so it can be moved by the 'GrabSpring' if the simulation is paused
Entity.IsActive = true;
if (!isEntityDynamic)
{
Entity.BecomeDynamic(1f);
}
// Must be disabled AFTER becoming dynamic
Entity.IsAffectedByGravity = false;
// Can I assign a rule to this entity's collision pairs?
// This way the other object in the collision pair will also react in the same way as this object for that particular collision.
if (!(Entity.CollisionInformation.Tag is EntityAttractor))
{
Entity.CollisionInformation.CollisionRules.Personal = CollisionRule.NoBroadPhase;
}
LocalOffset = Vector3.Transform(grabLocation - e.Position, Quaternion.Conjugate(e.Orientation));
GrabbedOrientation = e.Orientation;
GoalPosition = grabLocation;
angularMotor.Settings.Servo.Goal = e.Orientation;
angularMotor.Settings.Servo.SpringSettings.StiffnessConstant = 60000f * Entity.Mass;
angularMotor.Settings.Servo.SpringSettings.DampingConstant = 900f * Entity.Mass;
angularMotor.Settings.MaximumForce = 10000f * Entity.Mass;
angularMotor.Settings.VelocityMotor.Softness = .1f / e.Mass;
// The stiffness, damping, and maximum force could be assigned during setup if the motor
// needs to behave similarly for entities of varying masses.
// When using a fixed configuration, the grabspring will behave weakly when trying to move extremely heavy objects,
// while staying very responsive for sufficiently light objects.
linearMotor.Settings.Servo.SpringSettings.StiffnessConstant = 60000f * Entity.Mass;
linearMotor.Settings.Servo.SpringSettings.DampingConstant = 900f * Entity.Mass;
// An unlimited motor will gladly push the entity through other objects.
// Putting a limit on the strength of the motor will prevent it from doing so.
linearMotor.Settings.MaximumForce = 10000f * Entity.Mass;
linearMotor.IsActive = grabSpringMode == GrabSpringMode.Rotation ? false : true;
}
What is going on?