# 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. 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? 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. :/ Dec 31 '17 at 23:10
• Have you checked the joystick calibration in the control panel? For example: maketecheasier.com/calibrate-game-controller-windows10 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. :/ 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? 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. 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 Oct 30 '18 at 15:54

Thank you very much for the solution. In fact, I found double entries in the Input Manager. "Horizontal" and "Vertical" had each 2 entries. I deleted the second entries, they were empty, and the problem was away. It never came back. Before that, I was searching for a couple of days with no positive result. Goto: Unity -> Edit -> Project settings -> Input Manager -> Search for the second entries "Horizontal" and "Vertical" -> Rightclick -> "Delete Array Element" That was all. I couldn't believe it. Thank you, thank you, thank you !!!

• There actually is a reason why the Input Manager has two entries each for Vertical and Horizontal! The second entries aren't empty, they are meant to be for input from Joysticks, while the first entries are for keypresses... been this way since Unity 2.0 at least... Oct 24 '21 at 14:04