GS001: Creating the Player
What would a game be without a player?
Every game has a protagonist. At least one. A game without a playable character to control wouldn’t be fun, would it? We want to get something up and running pretty fast here, therefore, we just create a placeholder for the player.
Creating the placeholder Player
Just right-click the Hierarchy window, select 3D Object > Cube and here we go! We have our protagonist which is portrayed by a cube now!
You might want to directly rename your just created GameObject to “Player” by just typing out your desired name. This will make it easier to know what your GameObject actually is. Just think about a large project where you have thousands of GameObjects simply called “Cube” or “Sphere”. It wouldn’t make it easy to find the GameObject you want to find, would it?
If you missed the chance and need to rename your “Cube” GameObject, simply click it in your Hierarchy and change the name in the Inspector to “Player”.
Creating references with tags
To make it easier for us to reference the Player in scripts later on, we should create a tag for it. Select the “Tag” dropdown and set this object to the “Player” tag. That’s done pretty quickly:
Make your player colorful!
If you want to, you can further customize your player cube with some color:
- Right click in your Assets folder in the Project view
- Create a new folder called “Materials”. We want to keep all of our assets organized!.
- Right-click the just created Materials folder. Then, choose Create > Material from the context menu
- Name your material. To make things easier, call it “Player_mat”, as we automatically will have a reference for what this Material is for.
- Click on the “player_mat” GameObject and search for “Albedo” in the Inspector.
- Click on the color panel and choose your favorite color from the color picker
- And finally, drag the “player_mat” object and drop it on the “Player” GameObject.
If done correctly, you should notice how the player cube has changed its color!
Nice! We just personalized our placeholder player Cube!
In my next article, we’ll take a look at how we make our cube move!