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,
We will proceed to add a GameObject. To do this, we can either select GameObject from the main menu,
From here we select a 3D object then cube
This can also be done from the Hierarchy window by right-clicking in the window, selecting 3D Object and then Cube.
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.
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.
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 _mat after all your material name. This makes it easier to find them when you have hundreds of assets in your project.
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 X out of the color wheel app.
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.
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.
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.
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.