Creating A Basic Player Object

Kenny Pruitt
Unity Coder Corner
Published in
3 min readFeb 17, 2023

Objective: Create A Basic Player Object

Before creating Player movement, we must first create our player. To start with something simple, we will create a cube and make it our Player object. This can be change later to anything you want the player to be, but for now, we will make a simple Player object for reference. To do so, simply right click in the Hierarchy of your scene, go to 3D Object, and select Cube.

Next let’s create a custom material for our Player object. It is good to have already created a Materials folder in your Assets folder for better organization, then once you have this, go into your Materials folder, right click, select Create, then select Material.

To edit the material you just created, just click on it and view the options in the Inspector window. If you’d like to simply change the color, click on the Albedo color palette and select the color you would like to use.

After the material is made, then you can simply click and hold the material and drag it onto your Player object in the scene view and drop it onto it to apply it to your Player object.

Next we will start on creating the core of the Player mechanics. To do so, first make sure you have a dedicated folder to store scripts in for better organization, then in your Scripts folder, simply right click, select Create, and select C# Script.

This is very important, while the new script is still highlighted, type in the name of this new script. If you don’t, the Class of the script and the name of the script will not match and will cause an error. If you mess up you can always change the Class name of the script in the code editor. To double check this, you can simply double click the script to open it in Visual Studio and check to make sure the Class, where it says “public class” has the same name as the script you created in Unity. If not, make these two names match, or they will not work properly.

To add your Player script to your Player object, you can simply click on your Player object in your Hierarchy and in the Inspector window, click the Add Component button, type in the name of your Player script and click on it to add it.

--

--

Kenny Pruitt
Unity Coder Corner

Unity Game Developer, C# Developer, and Software Engineer