Recently, there are many 3D game engine around us, such as CryEngine and Unreal Engine. However, in this tutorial, we will learn a different one, called Unity – one that powers in many platforms and game genres.
Multiplatform supported by Unity
Install and setup:
First, let’s get a free version of Unity at: http://unity3d.com/unity/download/
After the installation, let’s open Unity.exe.
It will ask you either login or create a new account. If you didn’t have one, create one now.
After login, there will be a pop-up window as below:
Let’s create a folder for our project. I named mine as UnityTut1.
Check Character.Controller.unityPackage and Scripts.unityPackage
Now, we will see our main workspace.
To familiar with the control, let’s create a game that you can walk on a plan and observe a sphere. Sound interesting! Let’s do it!!
First let’s create Plan that we can stand on it.
Go to Game Object/Create Other/Plane
There will be a plane on the scene as:
Now we can play with the camera a bit 😀
- Pan: Middle Mouse Holding/ Alt + Middle Mouse Holding/ Q
- Rotate: Alt + Left Mouse
- Zoom: Alt + Right Mouse/ Middle Mouse scrolling
- Focus: (in case you lose where your object is) Click the object either in the Scene or in the Hierarchy + F
Used to it yet?
Let’s position the plane in the center of the scene.
Click on the plane (either in the Scene or in the Hierarchy), we will see the Inspector panel change to a list of attributes of the plane.
Change the value of Position (all x, y, z) to 0.
Add a sphere to scene and position it above the center of the plane.
Go to Game Object/Create Other/Sphere
Position it in the center of the scene by change the Position (x, y, z) of the Sphere in Inspector panel to 0.
We will see the sphere in the center of the plane, but we want the sphere to be above. Let’s move it up!
We can see in the top-left corner of unity, there are 4 buttons:
From left to right we have:
- Pan: (shortcut P) move the scene camera around.
- Move: (shortcut W) move the selected object in X, Y, Z axis.
- Rotate: (shortcut E) rotate the selected object.
- Scale: (shortcut R) scale the selected object.
Let’s press W or click the second button. Click the Pointing Up Arrow of the Sphere and drag it up as:
Let’s add light to scene. Go to Game Object/Create Other/Point Light
Now reposition it to position (0,0,0). Move it up above the light (Press W).
Let’s add First Person Controller!
First Person Controller represent your view when you playing the game. So when you in the game, the view of player is the view attached in the Fist Person Controller.
In the search bar in the Project panel, we type First Person Controller. It will appear the object First Person Controller in the Project panel. Then we drag it to the Hierarchy panel as below.
- If you couldn’t find the First Person Controller object, it should because that you didn’t click Character.Controller.unityPackage when you create the project in Install and setup Step.
- To import that package manually, go to Assets/ Import Package/ Character Controller.
In the Scene, now should appear the object First Person Controller. We will try to position it somewhere around the sphere, but still above and inside the plane area.
Now let’s test the Scene.
Click on the Play button in the middle of top Toolbar, or press Ctrl + P.
The scene now should should as below:
Some basic controls:
- Up/Down/Left/Right Arrows: Move Forward/ Move Backward/ Move to the left/ Move the the right.
- W/S/A/D: same as Up/Down/Left/Right Arrows
- Space: Jump
- Ctrl + P: Back to working scene (Stop/Play)
- Ctrl + Shift + P: Pause/ Unpause
Now, try to move around the sphere, jumping on it, look around, jump down. Is it fun?
- If when you click Play, the scene is total blue, it may be that you didn’t position First Person Controller above the plane and inside the plane area together. Try to reposition it somewhere, or reposition it to 0,0,0 then move it up above the sphere and try again.
So I think you have found that this engine is amazing and easy to use. We are going to come up a lot better and advanced tutorial in order to help you make your own game with Unity. If there is any question, please feel free to leave a comment and tell us more about you, then we can provide better articles to you. Many thanks.