Search Unity

Input.GetAxis("Horizontal") is biased to -1

Discussion in 'Scripting' started by crinkelite, Nov 26, 2014.

  1. crinkelite

    crinkelite

    Joined:
    Nov 26, 2014
    Posts:
    6
    When I attempt to use Input.GetAxis("Horizontal") the object is moving to the left.

    The line

    Debug.Log(Input.GetAxis("Horizontal"));

    returns -1 to the console when I start the program. I can change it to 1 by holding down the right key for more than second but it instantly changes back to -1 if I tap the left key.

    I have disabled all inputs except the Keyboard/mouse.

    Seems a little weird to me and I can't find any other posts relating to the problem.

    Here is a copy of the script.

    #pragma strict
    var rotationSpeed = 100;
    function Update ()
    {
    var rotation = Input.GetAxis ("Horizontal") * rotationSpeed;
    Debug.Log(Input.GetAxis("Horizontal"));
    rotation *= Time.deltaTime;
    rigidbody.AddRelativeTorque (Vector3.back * rotation);
    }
     
  2. parandham03

    parandham03

    Joined:
    May 2, 2012
    Posts:
    174
    See input manager(Edit->Projects setting->input) Horizontal axis ->invert check box.If it is checked uncheck it.
     
    crinkelite likes this.
  3. crinkelite

    crinkelite

    Joined:
    Nov 26, 2014
    Posts:
    6
    Thanks Parandham03 for the quick reply.

    I tried it with the box checked and again with it unchecked. The results are exactly the same.

    The ball still rolls to the left and the console still reports the Horizontal axis as reading -1.

    I'd just like to add that I have drivers for a wiimote, a virtual joystick for freetrack and an xbox controller installed on this machine however they are not connected at present and I have set unity to only poll the keyboard and mouse.
     
  4. parandham03

    parandham03

    Joined:
    May 2, 2012
    Posts:
    174
    i cant understand.U mean unity gives -1 without pressing key?
     
  5. crinkelite

    crinkelite

    Joined:
    Nov 26, 2014
    Posts:
    6
    Yes

    Also, I can change it to 1 by holding down the right arrow key for a few seconds but it changes back to -1 if i just momentarily tap the left arrow.

    The axis reading is heavily biased to -1.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    There's no bias in Unity itself; your script produces an output of 0. Typically unwanted input means you have an uncalibrated gamepad or joystick plugged in.

    --Eric
     
  7. crinkelite

    crinkelite

    Joined:
    Nov 26, 2014
    Posts:
    6
    Cheers Eric, I suspect you may be right although I have been sure to enable keyboard and mouse exclusively.
    I believe the setting in (Edit->Projects setting->input) is not strictly adhering to it's intended purpose.
    Pity really as I don't want to uninstall every HID on the system, it took me a long time to calibrate them.
    (the headtracker is a bast*rd to set up and I use it daily)
    Any big brains out there have a suggestion?

    I should add that every input device listed in "Game Controller Settings" (win7 x64) is calibrated and zeroed correctly.

    This does not seem to be a deadzone problem.
     
    Last edited: Nov 26, 2014
  8. GetUpKidAK

    GetUpKidAK

    Joined:
    Apr 9, 2013
    Posts:
    84
    Any particular reason why you think this is the case?

    Have you tried unplugging any devices? Checking the value in another project?
     
  9. crinkelite

    crinkelite

    Joined:
    Nov 26, 2014
    Posts:
    6
    Sorry, I cannot continue the conversation at the moment, I'll upload screen shots tomorrow and hopefully clarify things.
    Thanks for the reply's so far. Please look in tomorrow if you have the time.
     
  10. crinkelite

    crinkelite

    Joined:
    Nov 26, 2014
    Posts:
    6
    The screenshot shows that the "key or mouse" should be the only device that unity is reading.
     

    Attached Files:

  11. GetUpKidAK

    GetUpKidAK

    Joined:
    Apr 9, 2013
    Posts:
    84
    That looks like the Input Manager is set up to the defaults to me. "Get motion from all Joysticks" is effectively checking all devices
     
  12. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    With the exception of gravity, which is usually greater than 0 (default: 3)
     
  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That particular input is set for key or mouse button, though. But since those are basically the input manager defaults, some of the other axes have joystick input, such as the second horizontal/vertical axes.

    --Eric