Moving a body in a specific direction using XNA with Farseer Physics
- by Code Assasssin
I have a custom polygon attached to a body, which looks like this:
What I am trying to accomplish is getting the body to move according to wherever the tip of the body is. So far this is what I've tried:
if (ks.IsKeyDown(Keys.Up))
{
body.ApplyForce(new Vector2(0, -20),body.GetLocalPoint(new Vector2(0,0)));
}
if (ks.IsKeyDown(Keys.Left))
{
body.ApplyTorque(-500);
}
if (ks.IsKeyDown(Keys.Right))
{
body.ApplyTorque(500);
}
The body rotates fine - but when I try making the body accelerate according to the tip of the body - assuming I have specified the tip correctly(I am pretty sure I haven't), it just spins around, as if I have applied Torque to it. Can anyone point me in the right direction of how to fix this problem?