Ever wondered what’s going on in the head of a game developer? Ever thought there’s more to a game than what you see? We will present you a series of posts explaining the kind of decisions we make throughout the making of a game and how we apply them. I guarantee you that you’ll be surprised by the amount of little unperceivable details it takes to make a game feel right, so hang tight as we will embark a journey into the entrails of Toto Temple Deluxe!

Today’s entry is about left and right controls, because it is important, in a game like Toto Temple, to have characters that are really fast and nimble for the sake of responsiveness, but still seems to be a part of a world with physics in it, in other words; we want the character to be an extension of the player, in the realm of the game.

Left and right must feel right

The character must move left and right with an acceleration and be constantly decelerated by friction, giving a good physically plausible, yet not floaty, feel to the character.
The character can be controlled on the ground and in mid-air, this is very important as the player will not touch the ground for most of his time, and there is nothing worse than dooming the player to a destination for the time of the jump.
Those accelerations and frictions must be different on the ground and mid-air, you must feel like you are in perfect control on the ground and like you are floating when you are in the air, just like in real life (if you were able to move in mid air that is)!

protected virtual float goSpeed(float speed) {
float addedSpeed; //Variable to store the speed added to the characterif (onGround) { //If the character is on the ground...
addedSpeed = accelX * speed; //The character moves normally
[...] //Other important yet irrelevant things for the current example
} else { //If the character is in the air…
addedSpeed = accelX * speed * airAccel; //It feels more floaty with less acceleration (airAccel is a fraction)
}
vX += addedSpeed; //The added speed is added to the character’s total speedreturn addedSpeed; //The added speed is returned for further verifications
}

The easing / skidding effect makes for a game that looks professional when done right, but can turn sour very easily and it comes with a fair deal of problems, one of them being the latency of the character to turn around and go the wanted direction. Solution: if the character is going in the opposite way as the controller dictates, the character is further accelerated toward the targeted direction, this tweak is less applied in mid-air to keep the floatiness.

Another skid problem being that the character continues moving toward the last input direction. Yeah, that’s the point of making the character “skid”, but do you know what happens to be in that direction? No, neither do we, it could be a pitfall or it could be a danger and it feels really wrong to have the character experience a significant event (even death) full tenths of second after the player’s last input. What if by releasing the controls he exactly wanted to avoid that thing ahead? The solution to this is an anti-skid system: we detect if there is such thing as a dangerous collision or no ground in front of the character, if one of those conditions are met and the player does not input any movement, the character stops immediately, significantly increasing the precision of the character controls in critical situations without sacrificing overall speed and feel.

if (!moving && onGround) { //If the player has not entered any input this frame and is on the ground...
tweakFrictionForThreats(); //Verify if there are threats and stop the character accordingly
}

Here’s a toto in danger of falling down, saved by the anti-skid system. Whew! Thank you anti-skid system!

Examples from other games

Finally, I’m leaving you with these little observations on other games, relevant to the subject:

In Super Meat Boy, there is the above mentioned latency to turn around when you change direction, but if you release the controls for one instant before changing direction, the friction is way greater when the character is idle, so it stops him way faster thus lightening the skid/latency.

Still in Super Meat Boy, the mid-air controls are a little funky: the character seems to have no friction in the air, so it is really hard to stand still in the air, it removes some control to the player, but it is a good idea in this game, to emphasize on the action by making the option of standing still more difficult.

In Legend of Zelda: Skyward Sword, it often happened that I released the joystick right before a cliff and because Link does not stop right away, he just continued and fell and it was rather unpleasant.

In Bit.Trip Runner 2 (great game, awesome sound design), sometimes you jump before reaching the enemy, but the character jumps a little too slowly, and just when you are about to celebrate another hurdle you jumped over (around one confetti worth of celebration), the obstacle takes your confetti and burns it to ashes as you stumble on it and cry.

In my opinion, controls are the very thing that can make or break a game, it is the base and foundation of every digital interactive experience and a really special care should be accorded to this aspect. And you, do you have an opinion on the way a character moves, in any game?

Funky, I don’t see text in the two input fields above this one (I’m on a current Firefox on a Linux Mint system). I’m getting auto-fill-in for e-mail on the right, so I guess left is my name. Is this an intentional riddle for the web-savy?
Anyway, nice post! I love to understand more about how games work. I program in PHP, which is of course page-related, and runtime programming is a riddle to me.

My academical course made that I have done a fair share of PHP programming, I was more comfortable with runtime (ActionScript3 or Unity C#). So if you ever try runtime someday, you’ll see it’s not too hard, it’s just a different way of thinking ;)

Very interesting post. I’d like to see the above mentioned developers’ take on this subject, as well as a few different others like Megadev when making Super House of Dead Ninjas or Chucklefish on Risk of Rain.

Very interesting post!
There are the same kind of small physics tweaks in Rayman Origins/Jungle Run. For example, you are still allowed to jump for a very small amount of time after falling from a platform. Or when you’re falling and press jump just before hitting the ground, the game remembers the input and makes you jump as soon as you touch the ground.
As you said, those very small things make the difference between an pleasant game and a frustrating game.

I’m playing Rayman Origins just right now, and you are right! They implemented several ways to make the game pleasant. However It’s a shame the physics play too much an important role, when you run up a slope you go significantly slower than on the flat, sometimes the speeds seem distorted because of this and you end up jumping way shorter or farther than you wanted.