Good 2D Platformer Physics

Posted by Joe Wreschnig on Game Development See other posts from Game Development or by Joe Wreschnig
Published on 2010-08-15T18:28:54Z Indexed on 2012/11/04 17:17 UTC
Read the original article Hit count: 286

Filed under:
|
|
|
|

I have a basic character controller set up for a 2D platformer with Box2D, and I'm starting to tweak it to try to make it feel good. Physics engines have a lot of knobs to tweak, and it's not clear to me, writing with a physics engine for the first time, which ones I should use. Should jumping apply a force for several ticks? An impulse? Directly set velocity? How do I stop the avatar from sticking to walls without taking away all its friction (or do I take away all the friction, but only in the air)? Should I model the character as a capsule? A box with rounded corners? A box with two wheels? Just one big wheel? I feel like someone must have done this before!

There seem to be very few resources available on the web that are not "baby's first physics", which all cut off where I'm hoping someone has already solved the issues. Most examples of physics engines for platformers have floaty-feeling controls, or in-air jumps, or easily exploitable behavior when temporary penetration is too high, etc.

Some examples of what I mean:

  • A short tap of jump jumps a short distance; a long tap jumps higher.
  • Short skidding when stopping or reversing directions at high velocity.
  • Standing stably on inclines (but maybe sliding down them when ducking).
  • Analog speed when using an analog controller.
  • All the other things that separate good platformers from bad platformers.
  • Dare I suggest, stable moving platforms?

I'm not really looking for "hey, do this." Obviously, the right thing to do is dependent on what I want in the game. But I'm hoping someone somewhere has gone through the possibilities and said "well technique A does feature X well, technique B does Y well, but that doesn't work with C", or has some worked examples beyond "if (key == space) character.impulse(0, 1)"

© Game Development or respective owner

Related posts about physics

Related posts about 2d-physics