Moving Dynamic Entity with an EntityMover prevents Gravity

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
al9191
Posts: 68
Joined: Wed Nov 16, 2011 11:19 pm

Moving Dynamic Entity with an EntityMover prevents Gravity

Post by al9191 »

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.

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;
}
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.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Moving Dynamic Entity with an EntityMover prevents Gravi

Post by Norbo »

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.
al9191
Posts: 68
Joined: Wed Nov 16, 2011 11:19 pm

Re: Moving Dynamic Entity with an EntityMover prevents Gravi

Post by al9191 »

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.
Post Reply