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

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);
}

See input manager(Edit->Projects setting->input) Horizontal axis ->invert check box.If it is checked uncheck it.

1 Like

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.

i cant understand.U mean unity gives -1 without pressing key?

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.

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

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.

Any particular reason why you think this is the case?

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

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.

The screenshot shows that the “key or mouse” should be the only device that unity is reading.

That looks like the Input Manager is set up to the defaults to me. “Get motion from all Joysticks” is effectively checking all devices

With the exception of gravity, which is usually greater than 0 (default: 3)

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