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

Player Movement Systems

Topics: Developer Forum, User Forum
Feb 19, 2014 at 3:07 PM
I am working on a project were in class my group of students help produce a video game. We are creating a 2D platformer and was trying to make a pixel based system collision witch fell through. Now I am trying this physics engine on for size and see newer ways to create and control my player. Like the obvious circle body player : Image

I was using a different type of player movement system like this one : Jumping (XNA Platformer Example)

I wanted to know what would be best for a player that needs to jump and move in mid air like the XNA Platformer Example, and can run up slopes like the circular body example. I guess that the circular body can be made to do anything but would like community input.
Feb 19, 2014 at 3:50 PM
Edited Feb 19, 2014 at 3:51 PM
Short (and unsatisfying) answer: Don't use Farseer (or any physics engine for that matter) for platformer physics.

The best you can hope for is a very whacky and unstable character. You need to manipulate a lot of stuff by hand, which Farseer won't like and have to tune a bazillion things, which you'll have to tune again every time you change something in your basic mechanics. In my opinion not worth it!

Just go for a simple box collider like that from Platformer Example. If you want your PC to interact with physics objects like boxes, balls, etc. add a kinematic body to the physics simulation and update it according to your platformer character logic by setting it's position or even better linear velocity directly each frame before stepping Farseer.
Feb 20, 2014 at 1:39 PM
The reason why I am trying to use this type of physics engine was because first, I tried using a pixel based collision system were it would call on the texture boxes and the map texture and if colliding would set true and stop the player but the collision system would not respond fast enough to be a way of collision. I tried so hard to make it work but in the end I came up with the conclusion that is was impossible. Video, post that made up my conclusion : Here, and Here. I then found a game called Dark, using Farseer and a lighting engine the game designer, Andrew Russell, created a rigid body that only had one point that collided with the ground and is a little floaty but worked.

He also added in a map editor that he could create any type of object with out any problem. This was what I was trying to achieve with my pixel based system were it would take little time to set up a map and have the player collided with an object no matter what shape it was. I know that this physics engine would not really be something I should use but I wanted to recreate this type of design and have little Idea how to do this with out the physics engine.
Feb 20, 2014 at 3:16 PM
(Coming over from GDSE)

Farseer offers lots of APIs to create arbitrary shapes. The one I used was simply:
BodyFactory.CreatePolygon(world, myShape, 1f);
Where myShape is just a Vertices which is a list of Vector2 defining the shape - a diamond in the case of the Dark player. My editor works in a similar way.

I should say that the "floaty" jump mechanics in Dark are my fault - I used a very bad tuning for it. But this is just what I'm setting the player's velocity to. The underlying technique is still good. (The velocity-setting part of the code is totally independent of Farseer - you'd have the same code for a tile-based or pixel-based platformer.)

The jump tuning in Stick Ninjas is very much improved. If you want a good reference on jump mechanics, basically: how to set the velocity correctly based on player input, I recommend "Game Feel" by Steve Swink.
Marked as answer by ryanpfoy on 2/21/2014 at 5:15 AM