O'Reilly logo

Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation by James A. Henley, Matthew Johnson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating and Hooking Up Our PlayerController

We’ve discussed the degree of control that we want to give our player, so now it’s time to actually make that happen. We’ll do this with a PlayerController Component that we’ll begin scripting now by taking the following steps:

1. Open the First_Level Scene file.

2. Select the Player GameObject.

3. Click the Add Component button and choose New Script.

4. Name the script PlayerController and ensure that the language is set to CSharp.

5. In the Project Browser, select the newly created script and move it to the _scripts folder.

6. Drag and drop the PlayerController script onto our Player GameObject.

You’ve just added our controller Component to the player! Soon, this will allow the player to move around, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required