The Challenges of 2.5D Character Controllers in Unity Part 1


So I've spent a great deal of the last couple weeks working on Emilia's Character Controller and generally the underlying physics of Grumpywitch.

If you've never heard the term, a 'Character Controller' is the piece of code that tells the game really specifically how you move; how fast you accelerate, how high you jump, how fast you fall, how you interact with uneven ground or walls, and generally how it 'feels' to control your character. It's subtle, but just like lighting, color balance, sound mixing, camera framing and the like, the way you move has a really pronounced effect on the tone and theming of a game. A really good character controller is surprisingly hard to make (from both a technical and design perspective), but a really good one can be the difference between a boring, frustrating experience and a smooth addictive trance where you forget about your controller and just inhabit the game.

...My work have been mostly technical so far though. The bulk of my experience is in engines that work with pixels, using a lot of tile-based collision. Unity uses an implementation of Box2D, so everything is floating point numbers and vector math. For any artists out there, it's an awful lot like switching from Photoshop to Illustrator. Your art sensibilities carry over, but you have to tie your brain in knots to get the tools to behave how you expect them to.

So why is it difficult? After all, an engine like Unity does a lot of physics work for you. The problem is that, as a general rule, characters in games don't obey the laws of physics. There is no conservation of momentum, things float or use independent gravity values, stuff floats in the air, and to avoid having to simulate every joint and tendon of every character we give them invisible boxes or spheres that have to start and stop on a dime.

In general, using a physics simulation to make a good character controller for your game can be very difficult, because the numbers you want direct control over to make sure your controller matches your gameplay tend to be numbers the physics system also wants control over. You butt heads a lot, and for a lot of games (especially older style games like platformers) most of the physics calculation is wasted. It's certainly possible, and if you build your game around the controller you can even get really fun games out of it, but if you want to make the game feel a really specific way you gotta get your hands dirty.

(For the super technically minded, NVidia has a great summary of the problems with physics in character controllers here: http://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/CharacterControllers.html#kinematic-character-controller )

This has sort of been a general introduction to some problems I'm working with. I may go into some greater detail in later posts.