I have a dynamic object that is represented in the Space as a ConvexHull.
I am trying to use an EntityMover to move the object whenever a key is pressed on keyboard.
ConvexHull body;
EntityMover mover = new EntityMover(body);
//These are setup in the constructor, convexhull is created from the model and EntityMover is created as seen there.
public void move(float distance)
{
Vector3 rotateVector = QuaternionToEuler(Body.Orientation);
Vector3 pos = Body.Position;
pos.Z += (float)(distance * Math.Cos(rotateVector.Y));
pos.X += (float)(distance * Math.Sin(rotateVector.Y));
mover.TargetPosition = pos;
}
The method is passed in a value of 0.25f for distance, it is used more as a speed to move forward by. The dynamic entity spawns properly with gravity acting on until the EntityMover assigned to it is added to the Space. Once, this is done, the dynamic entity spawns and doesn't fall to the ground (spawned in the air to test if gravity was working properly). It can also not move properly anyway.
That is the correct behavior of the SingleEntityLinearMotor. It controls all three linear degrees of freedom. Gravity will pull on the shape, but the motor will pull it back up.
If you want fewer controlled degrees of freedom, you could use another 1DOF linear two-body constraint like the LinearAxisMotor (with one of the connections set to null, signifying a world connection) or use custom logic to define velocities which move the object exactly as you want.
ok thanks. I have custom logic to do it already. Just thought it might be nicer to use the EntityMover to do the job.
Will leave it with my custom logic using velocities.