This project has moved and is read-only. For the latest updates, please go here.

Question how to handle some particular cases with Farseer

Topics: Developer Forum, User Forum
Feb 24, 2010 at 11:26 PM

Hi everyone

i am programming a little "Mario Like" game  with the farseer physics engine and i've got some questions on how to implement certain things :

-My player has got a Body, and i move him without using any forces or impulse, collision works great but peraphs it's not the right way to move objects with farseer ?

-My player can jump and for this i used the ApplyImpulse fonction, it works great but when my player is falling under an ennemy head i want him to make a little jump while he erase the ennemy. I think i should add an other impulse and take in account the player's Velocity. But i wonder how i can do it the cleaver way ?


Feb 25, 2010 at 10:02 AM

Applying Impulse to "bounce" of the enemys head is one way, but I think you could also set the RestitutionCoefficient maybe? I'm not 100% sure, wait for a Farseer expert. :P

I personally, move my objects with ApplyForce, which I think its better than manually manipulating the body.Position variable, but once again, wait for a Farseer expert.


Feb 25, 2010 at 11:11 PM
Edited Feb 25, 2010 at 11:12 PM

thanks for your reply, it was very usefull.

RestitutionCoefficient seems to work well for this case, i juste set i when i jump on a player and remove it when i land on floor.

i tried to move my player using applyforce, but i didn't manage to make him move at a constant speed, without acceleration, do you know where i can look for this ?

Feb 26, 2010 at 5:36 AM

So, if I understand correctly, you want to go from a horizontal velocity of 0 to {x} instantly, with no detectable acceleration? Hmm, other than making 0 friction on the objects, and using ApplyForce, but I don't even know if that will work.


Feb 26, 2010 at 4:00 PM
Edited Feb 26, 2010 at 4:02 PM

The biggest problem with making player controlled characters in Farseer is avoiding having your player accelerate. You never want your character in your game to accelerate while moving because it feels awkward and abnormal as if the player has a lack of control. Obviously that goes without saying that you would want acceleration in the few cases where it does make sense such as if your character is a car, or a ball, etc. You should never be using ApplyForce to move your character because it does acceleration your player.

The best method I've discovered for doing this is setting the LinearVelocity for your character.