Input.GetAxis(Horizontal) problem

Wen i use Input.GetAxis(“Horizontal”) its pressing alone all by itself, i even tried unpluging the keyboard and nothing, this is a little code i used to figue it was failing:

function Update () {
	
	if(Input.GetAxis("Horizontal"))
	{
		print("Input: " + Input.GetAxis("Horizontal"));
	}

}

And what i get in the console whitout pressing any button is:

Input: -1

wish means its pressing to the left but i dont press any button.

the only diferent thing i did was update to 3.5.5f3

started the game and my character was waliking to the left o.O

i changed to previus version and the same thing keeps happenig, any ideas on what could be happening?

The best way to solve this from the programmer end is to write your input scripts to deal with it. Currently, your game (by default) accepts Hortizontal and Vertical Axis info from the keyboard or a joystick. They are labeled the same in the Input Manager… That way you can write code like:

 float translation = Input.GetAxis("Vertical") * speed;
 float rotation = Input.GetAxis("Horizontal") * rotationSpeed;

And it wont matter if the player is using a keyboard or a joystick. Unfortunately when a player has something going on with their joystick stuff (virtual joysticks seem to cause issues), the Axis gets all wonky… Players report spinning around that won’t stop.

BUT… If you change the name of your second set of Horizontal and Vertical Axes in the Input Manager (the ones that correspond to the joysticks) to something like HorizontalJoy and VerticalJoy then they won’t interfere for your keyboard-only using player. You could then add a toggle on your Controls or Pause menu to enable Joystick controls.

then you might write code like this:

if( !joystick )
{
 //if joysticks aren't enabled - just track keyboard axis 

 float translation = Input.GetAxis("Vertical") * speed;
     float rotation = Input.GetAxis("Horizontal") * rotationSpeed;
} else {

 float translation = Input.GetAxis("VerticalJoy") * speed;
     float rotation = Input.GetAxis("HorizontalJoy") * rotationSpeed;
}

Below is a screenshot of the input manager - notice the second set of Horizontal and Vertical Axis are called HorizontalJ and VerticalJ. Do something like that and write code to allow for joy support if you want to give your user the option and the bug should be fixed on your end and the users. This also means joys won’t really be tracked unless you write code to watch the specific axis as stated above. This solution worked for my testers.

[36256-screen+shot+2014-12-01+at+7.08.51+pm.png|36256]

It seems that the Horizontal axis Input settings have been screwed up - either by the Unity update or unintentionally by yourself. There are two Horizontal axes, one for button/key and the other for joystick input. Check if both Horizontal axes are set as below (default setting):

alt text

Similar to @jinhyuki my problem was caused by an extra non-existent HID, in my case it was a “HID-compliant game controller” that was the culprit.
alt text

Had a same problem.

My problem was fixed when I uninstalled virtual joystick I installed before, and disabled the virtual joystick driver.

My fix was to set Camera to MainCamera in the Tag section, NOT the name (for new people).

my fix was to just select (mouse click) the game window, when in playing mode :slight_smile: