Create a player in Unity

Creating a GameObject in Unity

Lets create an object for our project

We are making progress now. We installed Unity and we created our first project. Now we have to add objects to our project so it has meaning.

With our new project open,

New Unity Project

We will proceed to add a GameObject. To do this, we can either select GameObject from the main menu,

Unity Menu

From here we select a 3D object then cube

Creating a 3D cube object

This can also be done from the Hierarchy window by right-clicking in the window, selecting 3D Object and then Cube.

Creating a 3D cube object from Hierarchy window

We now have a 3D cube in our project. It will appear in the Scene window, in the Hierarchy list and if you have the Game window open you should see it there too.

Lets rename our cube as Player. This can be done by either right-clicking on the Cube in the Heirarchy window or by clicking on the word Cube in the Inspector window.

Renaming a GameObject

Our player is pretty plain, so lets give him some color. To do this, lets create a material to apply to our player object.

For organizational purposes, we will first create a sub-folder in our Assets folder that will hold all of our Materials. To do this, in the Project window, right-click on the Assets folder, select Create and then Folder. Name the folder Materials.

Creating a new Matrials Folder

Now we can create our new material within this folder. It is very similar to what we just did. Right-click on the Materials folder, select Create and then Material. Name the material Player_mat. As a naming convention, place the after all your material name. This makes it easier to find them when you have hundreds of assets in your project.

Creating a new material

With our new material selected, the Inspector pannel will show us this object information. We want to cahange the color of this material, so under Main Maps, Albedo there is a small white square. Clicking on the square brings up the color wheel. Here we can select a color for our material. When you have selected a color just out of the color wheel app.

Changing the color of the material

We have created our material and now we want to apply it to our Player object. To do this, we can either click and hold on the material, drag it on top of the player object (the cube) in the Scene window, or drag it on to the Player name in the Hierarchy window.

Applying material to a gameobject


Since this is a 2.5D project, we don’t need this 3D look we currently have, so to change this, we will select the Main camera from our Hierarchy window and then in the Inspector window under Camera, Clear flags, select the down arrow where it says Skybox and select Solid Color. Next you can select the color you want your background to be.

Changing background to Solid color

We also want to set up our game’s aspect ratio so that it has a proper appearance on most screens.

In the Game window, next to Display, it will normally say Free Aspect. Select the down arrow here and select the 16:9 aspect ratio unless you have a speific aspect ratio you want your game to have.

Changing the Aspect Ratio of the game

So we now have a GameObject in our scene and have set up the background. In my next article, we will be creating a script in C# to make our object move.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Marc Frappier

Marc Frappier

Poultry Scientist by profession, Computer Scientist at heart. After many years in the poultry business, I have decided to give my passion for technology a shot.