Unity Beginner to Hero Part 1: Introduction and Setup

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.

The initial set of ten tutorials build a basic first person shooter. Shown here is the character controller firing rockets at a target, destroying it.

The initial set of ten tutorials build a basic third person shooter. Shown here is the character controller firing rockets at targets to destroy them.

Unity primarily supports two programming languages, Javascript and C#. These tutorials will use C#, but their main goal is to teach Unity and not programming (although you’ll likely learn it along the way!). A great resource to learn C# is learncs.org. Unity has a broad documentation for their scripting system, found here. I find the documentation absolutely essential, but by and large the search system on their site isn’t that great. Instead, I find it best to just use google to search for pages on the documentation. Searches like “unity vector3” (with any class, method or other element in the place of vector3) are fast and accurate. Finally, Unity has a large forum to discuss the engine.

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.

Don’t worry too much if you want to change a 3D project to a 2D one—you can always change back by going Edit->Project Settings->Editor and changing the Default Behaviour Mode.

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.

2_Selection

Empty project with the 2 by 3 layout. Movement, rotation and scaling tools indicated in the top right.

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.

With the camera selected, the Inspector is populated with data.

With the camera selected, the Inspector is populated with data.

If you lose track of an object in the Scene view, select it in the Hierarchy, move your mouse over the Scene window and push F to focus on it.

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.

Lesson 1 Complete Project


Thanks for reading! If you have any problems with the above tutorial, general comments or suggestions, please post below. It’s always appreciated!

3 thoughts on “Unity Beginner to Hero Part 1: Introduction and Setup

  1. Under the picture you state “The initial set of ten tutorials build a basic first person shooter.” however the camera angle of the final lesson makes it a Third Person Shooter not First Person Shooter.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s