Commercial C2301Games Development 1181Game Engines – Introducing Unity

Commercial game engines contain all the code to render advanced graphics, manage game entities, load and release game assets, play audio, calculate physics, etc. Using a commercial game engine allows creating of high quality games without in-depth knowledge of the processes involved. For that reason, we have avoided using commercial game engines until now. However, they are widely used so it is worth getting to grips with them.

We can also experiment with advanced techniques that are difficult to demonstrate in small lab samples. With your existing technical knowledge, you should find using a game engine relatively straight forward.

Getting Unity

  • Unity is a large download. It should already be installed in the Games Lab. If you need to download it, follow the steps below:
  • Go to
  • Follow the “Get Unity Now” link to download the Personal Edition
  • Note: The Unity license is quite permissive – you can release small-scale titles royalty-free provided you include a Unity splash screen.
  • Installing will start a long download. So you might want to also select the optional content as you will be downloading a lot anyway.

Unity Documentation and Tutorials

Unity’s documentation can be found here:

There is a collection of official tutorials here:

Note that Unity recently updated to version 5.x and older 4.x projects may not work without change. If you experiment with other tutorials or sample games check the version required.

Register

  • The first time you run Unity you should register. You can use your university email.

Test Unity – Quick Feature Test

When Unity starts you see a list of projects – empty at first – and a getting started video that you might want to watch.

  • First a quick feature overview:

Open up a demonstration scene

  • Choose New to create a new project…
  • Choose a sensible name and select the 3D radio button
  • Click the Add Asset Package button and select all before clicking Done
  • NOTE: If there is nothing to select here, you will have to download and import the Unity Essentials -> Standard Assests package once the project has been created.
  • Click Create Project. It may take a couple of minutes to import everything…
  • When the main Unity window has opened you will see a blank scene.
  • In the bottom left of the screen, under the Project tab, Find the Assets folder.
  • Inside Assets > Sample Scenes > Scenes you should find a scene called Car. Double click to open it.

Basic UI Controls

  • In the Scene tab of the main part of the window (where your scene is displayed)
  • Click on things to select them. Or drag a rectangle around them.
  • Properties will appear in the Inspector tab to the right.
  • Click on or expand entriesin the Hierarchy on the left.
  • Double click in the Hierarchy to centre on a scene element.
  • Test the viewing controls:
    - Middle button drag = Pan (press Shift for high speed pan)
    - Right button drag = Rotate viewpoint
    - Alt+Left button drag = Rotate around point in front of camera
    - Mouse wheel or Alt+Right button drag = Zoom in and out
    - Click on the axes at the top-right to align the camera (underneath for isometric)

Selection and UI

  • In the Hierarchy, find and click on the ParticleBurnoutSmoke under Car Particles. The exhaust particles system is selected and animates.
  • Particle system properties will appear on the right, Try unchecking Size over Lifetime, the particles won’t expand as they travel.
  • At the top left of the Scene window experiment with the settings there (Shading, 2D, lighting etc).
  • At the top right of the entire window click the drop-down menu that says Layout. Try the various window layouts, then return to default.

Assets / Scripts

  • In the bottom pane, click on “Project” rather than Console. There you can see all the assets (models, textures) and scripts used in the project.
  • Open Assets > Standard Assests >Vehicles CarModelsSkyCar. A single click will display properties on the right, a double click will open it in an external editor. If you have e.g. Motion Builder, Unity will launch it as needed.
  • Look at the textures in ... Vehicles Car>Texture. No surprises here, but notice the distinctive blue normal maps.
  • Look at the … > Vehicles >CarShaders files. They will open up in Visual Studio. The shader language here is Cg, which is very similar to HLSL (in fact HLSL is also supported). Some of the code should seem somewhat familiar. There is some extra code at the top that helps interact with Unity.
  • Finally, look at … > VehiclesCarScriptsCarController.cs. These C# scripts control the car's game behaviour. This particular file does the car control.Although we have not used Unity, if you skimthe content it is fairly familiar control and physics code.

Running the Game

  • In the Unity main window press the Play button at the top. The game runs. Keys are cursor keys (or WASD) and space for handbrake. Change camera or reset game at top-left. There is a menu of other basic games at the top right (all the games are in this one project).
  • Press Play again to stop and return to the scene editor.
  • You can build a working executable in the File menu under “Build Settings…”. You can target several platforms. Experiment if you like.

Tutorials

To learn the details of Unity, we will use the official tutorials. As you are technically advanced compared to most beginners this will be easy and you mostly just need to learn the user interface. So move quickly through the tutorials.Run the videos in a second monitor, you should be able to keep up or even skip ahead on the simpler parts.

  • Go to:
  • If you have not used Unity before then go to the Roll-a-Ball tutorial and work through it. It should present no difficulties but will give you a basic overview of the workflow in Unity.
  • IMPORTANT NOTE: It is a good idea to use the same window layout as the tutorial videos. Once Unity has started, choose “2 by 3” from the top-right drop-down that says “default” at first. Then drag the “Project” pane underneath the “Hierarchy” pane so that they each take up half the vertical space.
  • If you have used Unity before, then choose a tutorial or existing project at your own standard. Experiment with a feature you haven’t tried before such as physics or altering shaders. There are many complete projects in the Unity asset store:
  • When you finish the first tutorial, move on to the Space Shooter, or if you wish the Survival Shooter (although you will miss some concepts if you skip the second tutorial).
  • You need to download the assets for these tutorials first - the first link in the tutorial. Then you need to import them into an empty scene as described in the tutorials. If you need to find assets you already downloaded later on they are in the “Asset Store” pane - press the ‘arrow pointing at a disk drive’ icon.
  • IMPORTANT NOTE: The second and third tutorial were made for Unity 4.x, but still work in Unity 5.x with minor differences. Make sure you have “Annotations” on in the YouTube window – press the gear icon.

The objective of this early Unity session is to get everyone to a basic level on Unity so we can look at some advanced topics in the second semester project, where we will join up some of the advanced technical knowledge we have into Unity projects. You could also consider writing games of your own in Unity to enhance your CV or even make some money!

C2301 - Games Development 1, Week 13 / Lab Worksheet 1-1