Moving Dynamic Entity with an EntityMover prevents Gravity
Posted: Tue Dec 20, 2011 1:19 am
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.
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.
I am trying to use an EntityMover to move the object whenever a key is pressed on keyboard.
Code: Select all
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;
}