You can keep up with all the posts from the series :
-The Making of Toto Temple Deluxe: Platforming (Part 1)
The Making of Toto Temple Deluxe: Platforming (Part 2)
The Making of Toto Temple Deluxe: Collisions for Platforming
The Making of Toto Temple Deluxe:The Unique Experience
The Making of Toto Temple Deluxe:The Unique Experience
The Making of Toto Temple Deluxe: Evolution Through Iteration

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) {

if (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)
}
}```

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.

```protected override float goSpeed(float speed) {
if (speed*speed < 0.25f) { //If the player input speed is too slow
speed = 0; //Just ignore it
}
if (speed > 0 != vX > 0 && vX!=0) { //If player input goes against the current character speed
speed *= 1.75f; //Boost the input speed
}
return base.goSpeed(speed); //Process the speed on a deeper level, previously shown
}```

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?

### Join the discussion 15 Comments

• Jeremy says:

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.

• Alexandre says:

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.

• Tim says:

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.

• Alexandre says:

Yeah, I believe it is interesting to know the dev philosophy of a developer who makes games you like. Stay tuned as we have many many more coming!

• Toni says:

Oh, wow! 🙂 That was unexpected ~ It’s amazing that you’re showing how you made the programming in Toto Temple deluxe! 🙂 I’m looking forward for more things like this about the game 🙂

• teilnehmer says:

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.

• Alexandre says:

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 😉

• Paul Nicholls says:

Thanks for the interesting article…looking forward to part 2 (if any) 🙂

• Diego says:

Hi there, you physics controls seems pretty nice! Is the source code for this jam game available anywhere? I’d love to take a look in the full platform code

• Alexandre says:

We won’t give out the whole thing, but if you ever want to see parts of it, just ask!

• mahmoud says:

i love my games

• niquito says:

ok

• raphael says:

awesome articles thx 🙂
keep up the good work!

• Ramón says:

You use forces or velocity when you apply the speed?. In moving, jump and dashing. Thanks 😉

• Alexandre says:

I use velocity. Anyway force is exactly the same as velocity, the only difference is that it takes the rigidbody’s mass into account.