Hello there! Welcome to the world of Unity! If you’ve just stumbled onto this page, Unity is a game engine developed by Unity Technologies. With enough knowledge and practice, you can use Unity to build just about any kind of game possible. As well, it’s been used in a variety of other fields for all kinds of applications, from architecture to fitness to medicine. You can download it here.
This is a series of beginner tutorials for Unity engine. No previous experience with Unity is required. Some knowledge of programming will likely be useful, but I’ll try to keep it as simple as possible to ensure that everyone can follow along and learn. The first few tutorials will likely go a bit slow, to ensure that the reader doesn’t miss anything essential. As we move on, I’ll pick up the pace and cover more ground in less time. For more of an overview about the goal of these tutorials and their motivation, you can read a post I made about it here. In the first ten tutorials, we will be building a rudimentary third-person shooter, as seen below. Every tutorial will have the source project linked at the bottom.
Run Unity once it is installed. You’ll see the project wizard pop up. Click New to create a new project (duh). Select a folder you want to put it in, and give it an appropriate name (I’m calling mine UnityTutorialSeries). Below are two options, 2D and 3D. Select 3D. Click on the Asset Packages button and ensure none of them are selected (we want a completely empty project) and click Create Project.
You’ll be immediately greeted by the Unity editor with your new project open. I’m not a huge fan of the default editor layout, so to start things off I’m going to go Layouts->2 by 3. As well, we can simplify the project pane by clicking on the small icon and selecting One Column Layout. None of this is essential, but these are the layout settings I will be using for the remainder of these tutorials.
In this layout, Unity has 5 main panels: Scene, Game, Hierarchy, Project, and Inspector. The Scene view is where all of your editing of the game world will occur. You can navigate around by clicking the little Hand icon in the top left, and then clicking anywhere in the world to pan around. Scrolling the mouse wheel will zoom in and out. Holding right-click will allow you to rotate the view. As well, while right-click is being held you can use WASD to fly around the world, and QE to raise and lower your position. Hold shift to increase the speed that you fly at.
Let’s create an object. On the top menu bar, go to GameObject->3D Object->Capsule. You’ll now see a new object appear in the Hierarchy panel, appropriately named ‘Capsule.’ The Hierarchy panel displays all objects that are in the current scene; in our case, the Main Camera, a Directional Light and our new Capsule. You can either select these objects by clicking on their names in the Hierarchy, or you can click on the object itself in the Scene view. Once an object is selected, you can move, rotate, or scale it in the Scene view, by selecting one of the three transform tools on the top bar.
To make our object do something, we’ll need to write some code to tell it what to do. In the Project panel, select Create at the top (or right-click anywhere within the panel) and select C# script. Name it BasicMovement. Once you name it, Unity will spend a couple of seconds compiling your new code. Double-click your script to open it.
Each time you make a new script, Unity adds two default methods, Start() and Update(). Start is called once, when the object first enters the game world. Update is called each and every frame. Copy and paste the following line into the Update method.
transform.position += Vector3.right * Time.deltaTime;
Save your script and go back into the editor. Select your capsule, and take a look at the Inspector panel, situated at the far right of the screen. With no objects selected the panel is empty, but with your capsule selected it is filled with information about this object. Click the Add Component button, and you’ll see a new panel pop up with a number of subsections. Type the name of your movement script into the little search bar and add it to your capsule. (alternatively, you can drag and drop the script onto the object). Once the script has been added, Push the big play button up at the top of the editor.
You’ll now see your object moving in the Game and Scene view. If you can’t see your object in the Game view, this is because it’s not in front of the camera. You can either move the object in front of the camera in the Scene view, or you can select it and directly modify it’s positional coordinates in the Inspector. Setting it’s position to 0, 0, 0 will place it in the camera’s field of view.
That wraps up part 1. In the next section, we’ll add controls to our Capsule to move him around and explain how the script works in depth.