- Home /
Input.GetButton vs Input.GetKey
I'm working on a tps with the traditional wasd movement and correcting the character rotation according to its direction relative to the camera (by pressing w you see the character's back while pressing s shows the character facing the camera and so on). The problem is that, if I use Input.GetKey(KeyCode.A) for instance, it works but the key cannot be later changed in the input manager. On the other hand, Input.GetButton can be setup during the game but it doesn't work (it messes up the character rotation god knows why).
I never used Input manager but I'm sure someone can help you.
You probably need to provide more information like an example from your script for people to help with why the Input.GetButton messed up your rotation.
Answer by zombience · Nov 05, 2013 at 05:03 PM
try using
Input.GetAxis("Horizontal");
instead. That way the Axes can be assigned in the input manager, and specific keys can be assigned to + and - values for one axis (e.g. "w" for + vertical, "d" for - vertical). This will work for buttons and joystick.