The Input Carrot
This demo shows the "carrot on a stick" approach to controlling a character on a terrain. Use keyboard (WASD keys) or gamepad to move, and mouse drag to turn the camera. See below for an explanation.
Carrot Distance:
Find the glowing object!
Items Collected: 0

A "carrot on a stick" is an easy interaction design pattern that can beuseful when your game has a 3rd person camera for a character walking on a terrain.

When I initially started a prototype with a box character, I used the straightforward approach of turning the character immediately in the direction of the input. While responsive, it doesn't feel great because the sudden rotation is very jarring, especially with the 8-way input of a keyboard; it's a little better with an analog joystick. You can see the effect by moving the Carrot Distance slider all the way to 0.

To combat this, I use carrot on a stick logic. Instead of moving the character directly with the input, I move the carrot within the ground plane, and let the character follow. I then always face the character directly towards the carrot, and if its distance to the carrot is greater than the "stick" distance, it pulls the character towards the carrot. As I change input directions, the carrot moves around the character, who then turns and responds in a natural-feeling way, giving me fine control over facing and movement direction without jarring rotation.

When you move the slider all the way to 0.5, you can see the carrot axis moving with your inputs, with a moderate amount of space before the character starts to follow. With this approach, there's a tradeoff between snappy rotation and laggy movement, controlled very simply by the length of the stick.

For my 1.0 character diameter, a very short stick (such as 0.08 here) creates a very snappy and responsive turn that provides slightly more smoothness over using the input directly. A much higher stick distance (such as 0.5), allows the player to easily turn the character in place with precision, especially with a gamepad, but introduces significant lag before movement begins. In this case, I've found that about 0.2 seems to be the sweet spot for the experience I'm building.

The simplicity of this technique is very appealing, and I used a similar approach when building the input system for Crucible at Amazon. It's reliable, high performance, and intuitive. I find that learning and creating simple building blocks like this is the best way to build engaging experiences.