# Input.GetAxis returns wrong sign only for 1 and -1

I'm using an Xbox 360 controller on Windows 10 with Unity, and the maximum values have the opposite sign as the rest of that side. For example, if I tilt the stick up, I get values from 0.1 to 0.99, but then I get a -1 when the stick is at maximum. Have I configured it to be this way by mistake? I have reproduced the issue in a clean project and using another controller.

void Update () {
float pitch = Input.GetAxis("Vertical");
Debug.Log (pitch);
}


I have discovered that if the axis is inverted (i.e. not as shown in the image) then returned values have expected signs. I will add this workaround as an answer for anyone else who may encounter this problem, but I will refrain from accepting it to allow for answers addressing the root cause.

• That's really odd. Might be a Unity bug. – Draco18s no longer trusts SE Dec 31 '17 at 1:27
• Hm! I've never seen this before. Are you able to reproduce the issue with different controllers, or in a fresh project? – DMGregory Dec 31 '17 at 3:56
• @DMGregory Yes, I have reproduced it with a different controller (but I only have one USB wireless dongle) and in a fresh project. :/ – Tashus Dec 31 '17 at 23:10
• Have you checked the joystick calibration in the control panel? For example: maketecheasier.com/calibrate-game-controller-windows10 – Ed Marty Jan 1 '18 at 3:02
• @EdMarty Thanks for the suggestion, but calibration didn't change it. The issue isn't present in control panel. :/ – Tashus Jan 1 '18 at 22:23

I had previously discovered a workaround that gave me reasonable behavior but did not reveal the underlying problem. I have revisited the project and have determined the root cause.

Two axes were named "Horizontal".

It seems that the InputManager by default has two axes named "Horizontal" and two axes named "Vertical." Deleting one of the sets completely solved the issue.

The previous solution:

Setting the axis to inverted causes the returned values to behave in a sensible way. Now if I tilt the stick up, I get values from -0.1 to -0.99 and -1 when the stick is at maximum, and I get values from 0.1 to 0.99 and 1 when I tilt the stick down. I can just as easily write my script expecting an inverted axis, so this allows me to continue. Unfortunately I still don't know what is causing the odd behavior when the axis isn't inverted.

• when inverted, what happens as the stick moves to maximum down? – Stephan Oct 30 '18 at 15:45
• @Stephan Edited. Unfortunately I have not worked on this project for a while, so I am not sure whether I can still reproduce this behavior. – Tashus Oct 30 '18 at 15:51
• Should be easy enough to test. I'll spin one up later this afternoon, and get back to you – Stephan Oct 30 '18 at 15:54