There have been a couple threads about this already, but no solutions as yet. So, I decided to make this the official 2D platformer thread for Farseer. If you have tried to make a 2D platformer using Farseer, post here and let others know what you did,
what worked, what didn't, etc..
What I've done is use a sphere body for the character. I have a few goals:
1) Detect when the character is "standing" on a platform (for now, a rectangular static body). Must differentiate between hitting the side of a platform and standing on top of it.
2) Allow horizontal movement while the character is standing on a platform, but set its linear drag coefficient relatively high, so that the character quickly slows to a stop when the player isn't pressing left or right.
3) Don't let the character fall off the edge unless they are have the movement key down in that direction (less frustrating for player).
4) Only allow "jumping" (an instantaneous upwards impulse force applied at one time) while the character is "standing" on a platform.
5) Set the linear drag coefficient to zero while the character is in the air.
I'm not sure yet how to detect "standing" verses "in the air" or "in the air but hit the side or bottom of the platform". Right now I have a "standing" toggle that is set to true when a collision between the character and a platform is detected, and false after
a jump (which can only occur while standing is true). It works fairly well except that if you touch the side of a platform standing gets set to true and suddenly the character floats in the air like it has a parachute (the linear drag coefficient in effect),
and the character can do an air jump.
Any ideas on a solution to this? Also, I don't have any ideas about to implement number 3.