- Home /
How do I bind a command to a key? [Beginner/C#]
I'm attempting to make it so that when you press the key "R", the game loads from level one. I have the application load code, but I don't know how to bind keys to specific commands. Help!
Comment
Best Answer
Answer by TonyLi · Mar 13, 2014 at 02:13 PM
In an Update() method, check Input.GetKeyDown():
KeyCode key = KeyCode.R;
void Update() {
if (Input.GetKeyDown(key)) {
Application.LoadLevel(1);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613140140im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
need help about these codes 1 Answer
Nested Coroutines Waiting for Each Other 1 Answer
Using Mecanim Trigger with same Key 1 Answer