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.

Input configuration

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

enter image description here

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.

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

  • 1
    \$\begingroup\$ when inverted, what happens as the stick moves to maximum down? \$\endgroup\$
    – Stephan
    Oct 30 '18 at 15:45
  • \$\begingroup\$ @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. \$\endgroup\$
    – Tashus
    Oct 30 '18 at 15:51
  • 1
    \$\begingroup\$ Should be easy enough to test. I'll spin one up later this afternoon, and get back to you \$\endgroup\$
    – Stephan
    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 !!!

  • \$\begingroup\$ 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... \$\endgroup\$ Oct 24 '21 at 14:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .