Input not found?

Heya.

I got a problem.

I defined an input in the Project Settings → Input, named “Fire”.

The input in made like that :

Name : Fire
Positive Button : w
Alt Positive Button : joystick button 0
Gravity : 1000
Drad : 0.001
Sensitivity : 1000
Snap : false
Invert : false
Type : Key or Mouse Button
Axis : X acis
Joy Num : Get Motion from all Joysticks

I made a player script in wich I use this code :

		if(Input.GetKeyDown("Fire"))
		{
			Debug.Log("bang");
			FireMachinegunBullet(myTransform.localPosition);
		}

But when I’m launcher the simulation, the log tel me:

UnityException: Input Key named : Fire is unknown

Do anyone encountered the same issue and got a solution?

Check the docs for GetKeyDown() (and related functions) and GetButtonDown() (and related functions). These two sets of functions do different things.

2 Likes

You probably want to use Input.GetButton

I think Input.GetKey is only for keycodes, not the input manager keybindings.

2 Likes

Use Input.GetButtonDown() rather than Key. Input.GetKey/Input.GetKeyDown is specifically for keys on your keyboard. The “Button” commands pertain to your input buttons.

2 Likes

Thanks, it work now. :]

Thank you brother.

In the future, please use the like button instead. You’ve just necrod an 11 year old post.

Thanks.