c# - Input.KeyDown() returns error but Input.GetKeyDown() does not -


i'm having weird problem. i'm trying make object move in direction press long hold button. when use input.getbutton(), error direction use ("left," "right," "up," or "down") not defined, defined. if use input.getkeydown() instead, compiles usual.

using unityengine; using system.collections;  public class movementhandler : monobehaviour {      void update () {  //      if (input.getbutton ("left")) //does not work //          debug.log ("left");          if (input.getkeydown ("left")) //works             debug.log ("left");     } } 

input.getbutton , input.getkeydown take 2 different inputs.

input.getkeydown checks see if key "left" being pressed. being said, documentation says should using keycode object parameter, this:

if (input.getkeydown(keycode.leftarrow)) // reads left arrow key 

(see getkeydown , keycode docs.)

input.getbutton expecting check see if button object specified name being pressed.

if (input.getbutton("fire1")) //reads ctrl key 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -