- Home /
Duplicate Question
How to use getButton for movement control using keyboard?
Actually I was doing setup for Input. I found that I can use "Jump" easily but How can I use Horizontal and Vertical. I want to show you my exact problem its hard to explain in words.
if(Input.GetButton("up"){
transform.Translate(Vector3.forward*10*Time.deltaTime);
}
if(Input.GetButton("down")){
transform.Translate(Vector3.back*10*Time.deltaTime);
}
if(Input.GetButton("left")){
transform.Rotate(Vector3.up,100*Time.deltaTime);
}
if(Input.GetButton("right")){
transform.Rotate(Vector3.up,-100*Time.deltaTime);
}
I want to do similar function. I know I can use getKey here but I wanted to know how I can use getButton for this.
Get$$anonymous$$ey and GetButton do the same thing. Just one expects a $$anonymous$$eyCode, and the other wants the name of a button that's configured in your input settings.
Unless you have a specific problem, I think this is covered by the manual.
Follow this Question
Related Questions
Input trigger doesn't work 2 Answers
Get pressed Keyboard key after pressing UI Button 0 Answers
Detecting if 2 Buttons are pressed at the same time 3 Answers
Prevent 'Hold' Of A Mouse Click 2 Answers
Having GetButton act like GetKeyDown 1 Answer