From the course: Unity 5: 2D Movement in an RPG Game

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Listen to movement

Listen to movement - Unity Tutorial

From the course: Unity 5: 2D Movement in an RPG Game

Start my 1-month free trial

Listen to movement

- [Voiceover] Now before we can start moving the player, we're gonna need a way to capture input to tell when the keyboard is being pressed so that we're able to route that into our new map movement controller. Let's go into our scripts folder and create a new C# script called player. Then we'll open it up in MonoDevelop. At the top of our class we're gonna create a new private field that'll store reference to the map movement controller. We'll call this moveController. In our start method we're gonna set the moveController field value to equal GetComponent, map move controller. This will go and find the script on the game object and set the value for us. Now inside of our update method we're gonna start building out the logic for listening to key events. Let's go ahead and create a condition to test for the Input.GetKeyDown value for the enum KeyCode UpArrow is true. If it is we'll simply do Debug Log and we'll output Up key is pressed. Now let's save this, go back into our project…

Contents