moving the player around - 2d game

Topics: Developer Forum, User Forum
Mar 3, 2012 at 6:34 PM

hay,

i'm beginner with farseer, i want some help to accomplish this :

i have a 2D game , no gravity , and a player, i want when i press the directional buttons (right - left - up - down) to make the player advance to that direction AND rotate to it , just like a car , it rotates to the desired direction while moving to it ..

 

thanks 

Mar 3, 2012 at 10:51 PM

When you are trying the move your player with no gravity, you are going to want to use Body.ApplyForce() to move the player around. Then, you can calculate the rotation based on the direction it is moving.

Mar 4, 2012 at 4:58 PM

thank you jcicero09,

but if you can show me an example or how to use the  Body.ApplyForce() , and how to calculate rotation based on the direction it is moving..

 


Mar 4, 2012 at 6:30 PM
Edited Mar 4, 2012 at 6:34 PM

If you are making a car simulation this tutorial could be useful (made for the original Box2D in c++):

http://www.iforce2d.net/b2dtut/top-down-car

Some other great tutorials are found on this site (click on the tag Box2D  they are for the Flash port of Box2D):

http://www.emanueleferonato.com/

Since those are not .NET/Farseer tutorials you might have some trouble if you don't read c++ or ActionScript but the concepts are exactly the same.