First-person character controller

Demo Link

Controls:

Movement - A S W D
Jump - Space
Crouch - C
Sprint - Shift


Been working on this for a while, coupled quite heavily with the work I’ve been doing an a custom physics engine for meep. Mechanically it’s not very special, it’s a capsule-based kinematic character controller.

It’s separated by intent, so controls can be re-wired whichever way you like, or driven by AI or over the network.

There is a fairly advanced set of movement tech here:

  • non-linear acceleration
  • dynamic jump height
  • slide
  • wall run
  • wall jump
  • vaulting/manting
  • forced posture (can’t stand up from crouch under a ledge)
  • coyote time (jump after walking off a ledge)
  • traversing uneven terrain
  • no sliding on surfaces you can walk up on

The largest amount of effort went into making it feel alive, this is partly moving the capsule in “human” biomechanical ways, but a lot of it is just camera theater. That is - moving the camera is a way that feels alive.

Specifically - we track per-foot stride, and animate the camera based on actual steps, not just using an arbitrary sine curve. This gives continuity to all motion.

We have a notion of exertion and stability, walk it more stable than a dead sprint, and sprinting tired is less stable. Walking backwards is less stable too.

There’s respiratory simulation too, fairly basic, but it gives the camera that characteristic sway, especially under high exertion.

Then we also have leaning. When you rotate the camera suddenly, the character turns, but a human body has to anticipate the turn, so we lean the camera slightly, which makes it look “real”. When we turn while running - we do the same, which helps sell the motion.

We play with FOV ever so slightly too, which helps give convey speed of movement.

There’s also a hidden mastery layer, jumping on-stride gives you a minor jump boost, where’s jumping off-stride produces slight penalty. Running with synchronized breathing is a bit faster, those kinds of things, there’s a whole bunch of them but they all individually very minor. Intended to let the player grow into the character a bit more and express more control.

The idea with the controller was to offer a very wide range of controls and expression with very few actual buttons.

4 Likes

Any chance of a simulation of the character being drunk and the different levels of intoxication that affect motion, balance and vision?

1 Like

To a degree. The balance can be simulated, but not actual stumble. Vision - not so much. The character only hooks into camera controls, no post-processing.

And as far as stumbling goes - I intentionally didn’t add any locomotion failure into controller, so even if it will feel very “unstable”, the controller will still faithfully follow input, even if less efficiently.

I was thinking about how much to add to the character, and the line is quite arbitrary honestly. But I wanted something that’s applicable in most situations and let you traverse spaces with a lot of expression and life.

For example - there’s no “tactical spring”, because I don’t want to make the controller gun-centric. And there is no “aim down sights” for the same reason.

1 Like