Moving a body in a specific direction using XNA with Farseer Physics

Posted by Code Assasssin on Game Development See other posts from Game Development or by Code Assasssin
Published on 2012-10-09T23:49:39Z Indexed on 2012/10/10 3:54 UTC
Read the original article Hit count: 422

I have a custom polygon attached to a body, which looks like this: Custom Polygon Attached To Body 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?

© Game Development or respective owner

Related posts about c#

Related posts about 2d