Jetpack Physhics

Topics: Developer Forum
Sep 29, 2013 at 3:44 PM
I'm currently developing an 2D Platformer XNA game, and i'm using Farseer to handle the physics.

Before introducing Farseer I gave my player character upward thrust using this method.

if(KeyIsDown.W)
{
   player.velocity.Y -= 0.1f;
}

I would like to know which of Farseer attributes (such as Apply Force or Angular Velocity) I need to work with to achieve this same effect. And if you feeling generous a quick demonstration of how it might be implemented.

I have already attached a Body to my player and have the collisions up and running, but my current movement system is not compatible with Farseer.

Any help with this would be greatly appreciated!
Sep 29, 2013 at 10:35 PM
Assuming the variable "player" is your body then:

player.ApplyForce(new Vector2(0, -0.1);
Would incrementally increase the bodies velocity

or

player.LinearVelocity = new Vector2(0, -0.1);
Would set the bodies velocity at a fixed value.

Check out the TestBed and Samples in the downloads section for loads of great examples on achieving different effects.

Have fun
Sep 30, 2013 at 12:26 AM
Thanks for the help,

I ended up using ApplyLinearImpulse as I found it the easiest to implement.

I am happy with the results, but I am not sure what the benefits of the two options you suggested might be over the one I have adopted.

Still thanks for getting back to me, it's really appreciated!