Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a game that takes input from a joystick. If you tilt the joystick right, the ship moves right linearly according to how much the joystick is tilted. So if you tilt the joystick twice as much the ship tilts twice as much. This feels fine in cases when you want to bank the ship through a steep turn (ie. lots of tilt). But for small tilts, the controls feel far too sensitive. How do game devs flatten/smooth the effects of controls? Do I just take the log of the tilt? Mostly, I want to flatten things in the middle of the range of possible tilts.

share|improve this question

A common approach is to raise the values coming from the joystick to a power, for instance squaring them, which improves the sensitivity for small deflections but still allows you to access the whole range of movement with large deflections.

Usually a joystick value comes to you in the [-1, 1] range. You'll want to preserve the sign when raising it to a power, so you'd do something like this:

if (joy > 0)
    joy = pow(joy, p);
    joy = -pow(-joy, p);

Here's an interactive graph where you can see how this function works when you adjust the value of p. As you can see, the curve flattens out in the middle, meaning that a given joystick deflection produces a smaller response.

share|improve this answer
Or better still: joy = joy * Math.Abs(joy);, which has the advantage that a well-written Math library will avoid the condition, and its negative consequences on the cache, completely. – Pieter Geerkens Nov 26 '13 at 5:00
@PieterGeerkens Yes, it's important to maintain cache locality for the 1 to 4 times per frame that you process joystick input. ;) – Nathan Reed Nov 26 '13 at 5:05

Usually, a joystick axis goes from 0 to 1, with 0 being no movement and 1 being full movement. So if you are holding the left thumbstick halfway to the right, it would be 0.5f, and if you are holding it three quarters of the way to the left it would be -0.75f.

What I suggest is only registering movement if the value is bigger than some threshold. For example:

float minForce = 0.2f;

if (Math.Abs(Joystick.Thumbstick.Left.X) > minForce) {
    // Do Movement
share|improve this answer
This technique is otherwise known as a deadzone and was common with low-quality joysticks where the stick tended to lean slightly off-center which would cause unwanted inputs without the deadzone. One improvement I'd suggest is to scale the input once outside the deadzone, otherwise it will jump from 0 to minForce when leaving the deadzone. – congusbongus Nov 26 '13 at 6:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.