Working with Unity Engine

HarryA
5 min readApr 12, 2021

“Hey, you. You’re finally back. You were trying to read these blogs, right? Walked right into that blog postings, same as us, and that student over there.”

“Damn you deadlines. Life was fine until you came along. School was nice and lazy.”

— Uhh..

T..that was a meme, nothing too personal (or is it?).

Anyways, welcome back. In case you forgot we are trying to learn Unity engine, a game engine which is used to make video games, which is a popular choice among the market.

Last time we familiarized ourselves with Unity, what it is, it’s reputation in game developments and what it can do. This time we are gonna try and work with Unity engine.

Creating a Project

First things first, is to create a new project we are gonna work with. Starting the Unity engine will first direct you to the Unity hub which keeps all your projects in there. It also has different features like Unity tutorials, community postings and Unity versions as discussed in the previous blog.

In here we can create a new project or open any preexisting projects that you have. For now we are gonna create a new project with 3D as the template and lets call it “Game01”.

New Project

Unity Interface

Now that we have created a new project, next thing we are going to do is to take a look at the user interface we are gonna work with. Just like Eclipse or NetBeans, Unity also has different components in its user interface that are going to be useful for working on our project.

First look at the user interface will show us 4 separated panels. At the very center of the engine is the Scene view. This is where we are gonna work for the most part. It will display all the game objects created and the physics and adjustments accompanied by the objects. It also includes the Game view tab which will show how the game will be presented.

Scene Panel

At the top-left of the interface is the Hierarchy, which will display the different game objects we have on our scene. Right now the default objects currently on the scene are the main camera and the directional light.

Hierarchy Panel

Clicking on a game object from the hierarchy will display its properties on the Inspector panel on the right side of the engine. Inspector will be used to adjust or add components or properties on the selected game object.

Inspector Panel

At the bottom we have the Project panel. This will have the different game assets that can be used to adjust or update a game object from the scene by clicking and dragging.

Project Panel

You can freely click and drag these panels to whichever position you would like and you can go back to its default positions by clicking the Layout option at the very top-right and choosing default.

Rearrange Panels

Creating Objects

Next, we are going to populate the scene by creating various game objects that will be displayed on the game. For now we are going to create the basic objects that can be seen on an average game, the plane or the ground, an object to assume the player character and an object that will interact with the player object.

Creating an object can be done by right-clicking on Hierarchy panel or clicking the + option at the top-left of Hierarchy panel. First we will create the ground object by selecting 3D Object > Cube. You can focus on the object you want by clicking its name on the hierarchy and clicking “F” on your keyboard.

Adding a cube

Once the object is created, you can view it from the camera’s perspective or more known as the player’s perspective by selecting the Game tab beside the Scene tab. You can move the game Game tab at the side of the Scene tab by clicking and dragging to observed the changes you made on the Scene tab.

Game tab

But the cube looks small to represent the ground so we will fix that. While the game object we just created is selected, we can go to the Inspector panel and adjust some settings. In here we can see the component “Transform” which can be use to adjust the scale of the cube. We want to make the cube wider to represent a ground so we will give it a width of 15 on the x-axis and a length of 50 on the z-axis. We can rename the object to “Ground” and adjust it’s position from the camera angle.

Ground object

Next thing in the list is to create an object to represent the player character. We will go over the steps again from earlier but we will make a sphere object object this time, and we will move it over the ground object and rename the object as “Player”.

Player object

Observed from the camera’s perspective, the player object looks obscure by the ground object so we will give it a bit of a character. By right-clicking on the Assets tab on the Project panel at the bottom, we can select Create > Material. This material will represent the rendering properties of the game object. We can go ahead and choose a colour and click and drag the material to the player object. We will go ahead and rename this material as “PlayerMaterial”.

Object material

Lastly, we will make another sphere object and place it a bit over the player object and a bit closer to the camera.

Sphere object

Adding Physics

We now know what each panel does in the user interface, we now know how to create simple game objects and how to manipulate them and created them, and now that we have all these toys set up, we will now begin to play with it.

RigidBody is a component in a game object that can be added for it to act like it’s a real object, basically adding physics into it.

Adding RigidBody is simple, first select on the game object you want to add physics to, in this case we will select the player object we created. In the Inspector panel, if you scroll down you can see and select the “Add Component” option. In here we can quickly search for RigidBody and it will add to the player object. We will do the same and add a RigidBody to the sphere object we created and give it a mass of 25.

RigidBody component

Now that we added some physics on these objects, we can observe how they will perform by clicking the play button at the middle-top of the interface.

Game play

And there we see our object going as far as it can go.

That’s it bye.

--

--