Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development How to Make a Video Game Player Input and Cameras Move the Player with Animation

Timothy Van Cauwenberge
Timothy Van Cauwenberge
8,958 Points

How does the computer know to only use the arrow keys and not just any button on the keyboard?

How does the computer know to only use the arrow keys and not just any button on the keyboard?

1 Answer

This is largely determined by the script attached to the object that you intend to move with the arrow keys. In the script you would tell the object to move in the direction that you want it to move whenever a specific key is pressed. In this project we used the word "Horizontal" and "Vertical" to determine what keys to gather information from. The word "Horizontal" gathers information from the left and right keys and the word "Vertical" gather information from the up and down keys. Once we have this value we can assign it to the game object to move in the direction that the key is pressed. Unity assigns the word horizontal and vertical to the specific keys by default and you can see this in the Input panel located in the Project Settings option of the Edit Menu.