The All-Importance of Steering


The first thing I knew when I started designing Trafique was that I had to get the steering right.

The vast majority of driving games for PC, at least non-racing games, implement steering with the keyboard keys. This is awful. If you understand why this is awful and don't need me to tell you, skip ahead to the section "More than Just Mouse". Otherwise, let's talk about the different kinds of inputs.

What is a Steering Wheel Anyway?

Keyboard keys are a digital input. They have two states: on and off. Digital input isn't inherently bad, there are countless situations where that's exactly what you want, and even within an on-off binary you can still implement a double-tap, use multiple digital inputs together, or distinguish between a tapped input and a held input. To use an analogy, you're working with black and white, but dithering is still possible.

An analogue input is any input that gives a degree of "on-ness". The accelerator pedal on your car is an analogue input: it goes from not being pressed at all, to having the pedal to the medal. In computer systems, where digital inputs are always either 0 or 1, an analogue input can be any fraction from 0 to 1. (note: not all computer systems internally parse all analogue input as being from 0 to 1, especially in cases where the input device can have a state that the user may implicitly understand to be "reversed", but it's not really relevant if you say that you're scaling from 0 to 1 or from -1 to +1, the point is that an analogue input is a fraction in between a minimum value and a maximum value.)

A car's steering wheel is an analogue input, and a very artificial one at that. Unlike other gameplay control schemes, where you might be abstracting the process of walking forward, with steering a car, then unless your game mandates the use of a wheel accessory, you're representing one input scheme with a different input scheme, which is sort of weird if you really think about it. 

And we can get really deep into kinesthetic projection here, and how even though I'm making it sound like keyboard steering is an unworkable travesty, in your own life experience you've probably found keyboard steering to be perfectly fine for the games that use it because you just don't conceptualize it as being a steering wheel. That's why on a gamepad, steering is done with the left stick and not with the triggers, even though that would make just as much sense, because the left stick is already what you conceptualize as being the "movement controller".

And keyboard steering is fine for games like Far Cry or Grand Theft Auto because it's a compromise; the design has to accommodate control schemes for two different modes of play, and if those schemes are too different than either the modes will feel artificially distinct, or the player will just get confused, probably both.

But I'm making a pure driving game. I don't have to worry about compromising with an on-foot control scheme, because there's no on-foot, and I don't need to worry about the camera controls accommodating gun aiming because there are no guns. So if I'm free to let the control scheme be whatever it needs to be, what can I do with it?

More than Just Mouse

Trafique uses the mouse's horizontal axis for steering. I'm certainly not the first person to think of this; Halo's PC port used mouse steering for its vehicles, and the ARMA games have an innovative dual-input system where the mouse is used for fine steering and the keyboard for hard steering. ARMA's steering was a major influence on me, but my goal was to implement something like that, using only the mouse.

The naive implementation would have been to have the car steer in the direction you're moving the mouse, rotating as hard as the mouse is moving, and leave it at that. At that point, any dev with a clue would recognize that you obviously need at least a bit of a dead zone in the middle so that it's possible for the car to maintain a straight line, so that the car isn't steering left or right all of the time. 

Here's where things get more advanced.

The thing about a car's steering wheel is that it has an enormous range between its minimum and maximum input states. You can fully rotate it in either direction before it stops turning, but when you're not making a turn onto a perpendicular road, you're barely moving the wheel more than 20 degrees at a time. That is a massive diversity of input strength that almost no game input can give you. Even video game steering wheel accessories tend to have a piddly turn range compared to the real thing. Gamepad analogue sticks are, in practice, barely better than keyboard input on account of their size.

The mouse's movement axes are hard to discuss in analogue terms because there isn't technically a maximum value, or at least, not one a user will ever reach in the course of normal play. Mouse axis input is measured in terms of speed, and the max is how fast your hand can move a mouse while keeping it on a readable surface.

So there are, largely, two ways you can go about implementing mouse steering: one way, the first way I tried and which I found to not be very workable, is to tie steering strength to mouse horizontal velocity. The problem is that unless you pick up the mouse every single time you make a movement, then completing a turn means steering in the opposite direction. No matter where your mouse is, if you start moving in a direction, it records the same speed. There's no way to bring your mouse back to a neutral position, because in this scheme, the neutral position is wherever your mouse stops moving. And not only does this cause a problem of reverse-steering, it isn't how steering wheels work. Steering wheels need to be brought back to a neutral position before you can start steering in the other direction.

Instead of using the mouse's horizontal axis, then, I used the cursor's screen position, and measured its distance from the centre of the screen, then converted this into a value from -1 to 1. This is, functionally, how almost all games that implement mouse steering do it.

The problem is that then I wind up back at the same issue as with an analogue stick: screen distance is a large axis to work with, but it's still a limited axis. However, it's large enough that I can do some tricks with it. Tricks that should make the driving feel more natural, without you even noticing that it's happening.

In my mind, a smooth control scheme is one you don't notice, because when you execute an input, it does what you expect it will do. 

So while the input gets processed from cursor position as -1 to +1, this isn't the value that gets plugged directly into "steering hardness". 

Like I mentioned earlier, you need some kind of deadzone, where input below a certain threshold is just zeroed out. Car steering wheels have dead zones in real life, too: you generally have to move the wheel more than a few degrees before anything happens at all. 

But what I did was to go beyond just that: the steering has two outer bands of input: one on the low end. where input is muted for course correction. This is to represent gentle highway speeds where you're making adjustments to your direction, rather than changing your vehicle's trajectory. The middle band represents more significant turning and corner taking, and it takes up more real estate on your screen than course correction because Trafique is mostly urban driving where you're going to be cornering a lot. Finally, if you push the mouse to near the edge of the screen, the input gets magnified, as if you were cranking the wheel to turn it as hard as you can. 

The boundary of course correction and "normal" steering isn't really perceptible because the max bound of course correction is also the min bound of normal steering, but if you're paying close attention you can tell when normal steering leaps to cranking it. Furthermore, I made it so that while there's ranges within course correction and normal steering, once you're in the hard steering zone, you're turning as hard as you can. The intent of this is to get the snappiness of hard steering kicking in as soon as you're in the zone, without having some unusably absurd turning strength at the extreme edges.

So, uh, I hope that it is good and people like it.

Leave a comment

Log in with itch.io to leave a comment.