I found found out I could used key press statement an alt way

I was trying to figure out the differences between the two but I ended up with the same results.

[LESSON]
if (Input.GetKeyDown(KeyCode.UpArrow)){
print(“Up Arrow key was pressed”);
}

[Alternate]
if (Input.GetKeyDown(“up”)){
print(“Up Arrow key was pressed”);
}

One is used with keycode the other just simply says “up” to refer to the up arrow key being pressed.

Slightly different syntax with tested same result. :smile:

Happy Coding!

3 Likes

There is a great reason to do your alternate version too, the KeyCode.UpArrow will be permanently mapped to that specific key on the keyboard, where-as in your alternate version what-ever key the player has configured to “up” in the game settings can be used, for example, one player may use the up arrow key, another may use the W key…

Nice post :slight_smile:

2 Likes

Privacy & Terms