Game Camp Day 1 - Getting Started

This first day is about introducing general concepts around designing and coding games, including a brief history of games and introduction to the Unity editor.

1: Overview

Today we dive into understanding Unity3D, introducing us to both the 3D and 2D modes of building games. Today we will:

  • Learn about Unity's 2D features
  • Working with standard assets
  • Importing our own assets
  • Use the 2D level editor to build a simple castle level

1.1: Firing Up Unity

Assuming Unity is successfully installed, then getting start is as simple as Start > All Programs > Unity (Folder) > Unity. First, we'll start talking about just getting around the level editor, where we will manipulate our "scene" to make a game level and cover the following:

  • Making a new project
  • Windows of Unity Level Editor
    • Scene View
    • Game View
    • Inspector
    • Scene Tree
    • Project View
    • Console View
  • Discuss: What is a Level?
  • Discuss: What is a camera?
  • Discuss: What is an asset?

To get you started in Unity:

  1.  Start the program from the Start menu
  2. When prompted for a new project, choose:
    1. "2D"
    2. Under "Asset Packages", check the box for "2D"
  3. Successfully get the editor loading, and ensure in the Asset view you can see the folder "Assets > Standard Assets > 2D".

1.2: Adding a Character

Unity comes with a built-in 2D character that you can add to your scene to start building your game. To get the character working, we'll demonstrate:

  • Importing a package
  • Importing an existing asset (the character controller)
  • Adding an asset to the scene
  • Discuss: What is a Game Object?
  • Discuss: What is a Component?

Experiment with adding and controlling your own character in the scene:

  1. In the Assets view, go to the folder "Assets > Standard Assets > 2D > Prefabs"
  2. Drag & drop the asset "CharacterRobotBoy" into the scene
  3. Press Play
  4. Try playing again, this time use the arrow keys to try to move the character while they fall
  • Examine the character controller in the Hierarchy View, what are the game objects?
  • Examine each game object in the Inspector View, what are the components?

1.3: Adding a Platform

A gamer where the character just falls into nothing would be very boring. Better put something for them to stand on. This will introduce us to:

  • Colliders - Objects that stop over objects from moving through them
  • Physics Materials - A simulation of how the surface of something reacts on collision (EG, slipperiness and bounciness)

Experiment with adding a platform for your character to stand on:

  1. In the Assets view, go to the folder "Assets > Standard Assets > 2D > Prefabs"
  2. Drag & drop the asset "Platform04" or "Platform08" under the character
  3. Hit Play
  4. Try pressing the arrow keys to move the character while the character stands on the platform.
  5. Try pressing the space key to make them jump while the character stands on the platform.
  6. Try stopping the game and adding more platforms to make a little level.
  • Examine the platforms in the Hierarchy View, what are the game objects?
  • Examine each game object in the Inspector View, what are the components?
  • What's the highest the character can jump between platforms?
  • What is the furthest the character can jump between platforms?
  • Try standing right on the edge of the platform. What happens?

1.4: Simple Camera Tracking

One screen worth of game would be rather boring. Better make it so the camera can follow the character around. To accomplish this, we will learn about:

  • Parent-child relationships in the scene graph

The easiest way to make the camera follow the character is to make it a child of the robot boy. To do this:

  1. In the Hierarchy View, find the "Main Camera" object
  2. In the Hierarchy View, find the "CharacterRobotBoy" object
  3. Drag the "Main Camera" to be a child object of "CharacterRobotBoy"
  4. Try hitting play to see if the camera follows
  5. For best results, make sure the camera is centered on the character by:
    1. Select the "Main Camera" in the Hierarchy View
    2. Setting the "Position" of the camera to "0,0,-10" in the Inspector View
    3. Try playing again
  6. Now that the camera follows the character, use all of the platform types to make a longer level for your character

1.5: Simple Death

You now have a simple 2D platformer, with a character that can move, jump, and is followed by a camera. Still, there can be moments where the character falls off the platform and just falls forever. Time to kill them for their failure. To do this, we'll have to learn about:

  • Triggers - Objects in the game that run code when entered

The standard assets come with a built-in way of killing the character when they go somewhere you don't want: it's called the "killzone". Let's drop one into the level below the platforms to ensure the character dies when they fail:

  1. In the Assets view, go to the folder "Assets > Standard Assets > 2D > Prefabs"
  2. Drag & drop the "Killzone" prefab into the scene, below the level area and into any place that might normally "kill" the character
  3. Try playing the game and jumping the character into the killzone. What happens?
  • Examine the killzone in the Hierarchy View, what are the game objects?
  • Examine each game object in the Inspector View, what are the components?

1.6: Companion Cube

To add a new layer of interaction, we can also add an interactive object to our game from the base assets: a crate! This will introduce us to:

  • Rigid Bodies - Objects in the game that move with realistic physics

To add your very own companion cube to the scene:

  1. In the Assets view, go to the folder "Assets > Standard Assets > 2D > Prefabs"
  2. Drag & drop the "CratePink" prefab onto the canvas
  3. Try playing the game and seeing what happens
  • Examine the crate in the Hierarchy View, what are the game objects?
  • Examine each game object in the Inspector View, what are the components?
  • What happens when the player character touches the crate?
  • What happens when the crate falls into the killzone? Does it restart the level too?
  • Can you make a puzzle that can only be solved by the player pushing the crate?

Congratulations, you've made a basic game! What a great start to building your gaming empire.