Unity Course Notes

From Wikicliki
Revision as of 08:20, 12 September 2020 by WikiSysop (talk | contribs) (methods)

Jump to: navigation, search

Debbie's own notes on a Unity course I am taking towards the Unity Certification.


Lesson 1 - Welcome to Unity Certified Developer Courseware

Conducted by Koh Siang Leng, 5 Sept 2020, 10am


Note how some versions in unity hub have LTS and some do not.

Are you irritated cos unity updated and everything BROKE? Use version of unity LTS "Long term support" - a version which does not accept any new features but will be supported for about 2 years.

Also remember to have a 3 button mouse.

Economics of Games


Unity has its own ad platform which makes it easier for a developer to integrate advertising for monetisation. Analytics is used extensively in mobile gaming too. Should be integrated in from the very start... (How?)

Monetise in the form of...

  • Physical Purchase
  • Download
  • Subscription
  • Freemium
  • In game purchase
  • Advertising

Game Genres to think about...

  • Action
  • Adventure
  • Arcade
  • Fighting
  • Non-Game (<-- probably me)
  • Platformer
  • Puzzle
  • Racing
  • RPG
  • Shooter
  • Simulation
  • Sports
  • Strategy
  • Survival
  • Open world etc

Game Design Document and Technical Design Document

  • For small company - the document is nice to read but in practice sometimes along the way people do not update along the way as they are building and playtesting the game.
  • For big company - there is probably a dedicated team doing this all day, that's their job to make the roadmap updated all the time!

Game Production Pipeline

Step 1 Pre-production

  • Create the game design document and technical design document

Step 2 Production

  • Implementing assets and creating game play
  • building the game for release

Step 3 Maintenance

  • Fixing bugs and releasing patches
  • Incremental functionality improvements

Step 4 Upgrade

  • Building and releasing new content
  • Major additions and mods, such as new levels, seasonal content, special release (like upsize of your happy meal - it is easy to upsell when they are always interested in your product)

Job Roles


THEY WILL TEST THIS IN THE EXAM. take note on art director vs concept artist in particular.

  • Concept art = provides unifying point for art direction (hence commonly confused with art director role)

Getting Started / User Interface

Install the IDE

Set up the interface in an ergonomic way


Can even put inspector on its own on a 3rd col on the right.

Creating Game Object


Child & Parent Objects




  • What is the purpose of tagging? (common question in unity exam) - We say its used to find gameobjects (not grouping). It doesn't matter to Unity what is the gameobject tag. Its for the developer to find items with same tags.

Importing from Asset Store


GameObject Settings


Transform (moving)

You can be precise about the position you move in Inspector


Importing Packages the right way


  • Often there are clashes with basic assets like main camera, you can overwrite them all usually and ignore the warning.

Arranging Prefabs

  • (Mac) Command-D to copy, Command drag to drag with snapping (Ctrl-D for windows)
  • Command-delete to delete the prefab
  • Common rookie mistakes by students - trying to drag into the game instead of scene editor, or double clicking into editing the prefab itself instead of the scene
  • Create empty gameobject, put all the blocks inside it so this container holds all your blocks


  • Window > AI > Navigation > Clear & Bake
  • Change Agent size and other values to tune your pathfinding


  • Created an empty and put the maincamera as a child of the hero and its like a fps (3rd person view)! It works! (trainer approved)


Game Level Design

  • A game could be composed of several different levels.
  • With level design, you can progressively teach the player new skills in the game (hidden tutorials)

Examples of Game Level Design:

  • Basketball shooter game: a level design would occupy a finite space, be bounded to a basketball size with walls, have a basket on either end, and floor markings to indictate the play area.
  • 2D platformer games: consists of one continguous continuous background. level design elements are to facilitate game mechanic, placement of elements don't correspond to real world placement as much as game mechanic.
  • 3D shooter: level design dictated by mechanics of the game - cover mechanism allows player to duck behind objects, placement of objects and lighting allows game to be played effectively.
  • Endless Runner: obstacles test the player's reflexes, bounding or side wall conditions, overhead and underfoot tracks/wires elements.
  • Zombie Toys: cover for player, enemies in form of props, concealment point
  • Trainer shared an example of a game level design map drawn by his children. boss levels and all. :-D

Difficulty of game level

  • must not be too hard
  • must allow user to gain mastery progressively
  • after user has mastery, they will find it harder to stop playing your game

Lesson 2 - Managing Project, assets, game level

Additional Box Collider

  • Let's say you have many elements, what if your player decides to do a weird wall hug and squeeze thru your buildings and perhaps fall off the game map entirely?
  • In Inspector > Add additional box collider > Extend your collider
  • Remember to set your collidable items as "static"




Project Management

  • Naming convention
  • can be simple (human readable) or have a system (requires a legend for universal understanding amongst team members
  • eg in animation, dope sheet



  • Albedo map - flat colour without light
  • Normal map - makes detail on surface
  • Occlusion - shadow map
  • Emission - emit light



  • Shader > Cutout For alpha channel artwork - adds complexity quickly


Cookieandcutoutps.png Cookieandcutout.png

quiz qn examples

  • The breadcrumb in project window shows: FILE PATH OF SELECTED ASSET (you must select it first)
  • Acceptable formats for audio are: AIFF, MP3, WAV, and OGG. (Unacceptable -> MIDI, RCA, IFF, QuickTime, Egg, wav, avi)
  • Project Window toolbar allows searching assets by: Label and Type
  • Modifying organisation of assets is done in PROJECT WINDOW (assets is just your files on the computer)
  • The 2 script types supported are C# and UnityScript
  • specular property controls COLOUR and STRENGTH of reflection
  • the material property controls spreading of light on microsurface details: SMOOTHNESS
  • material rendering mode uses black in an alpha channel to define where material is exactly NOT appearing - CUTOUT
  • The albedo of a material is defined as: colour of the material without lighting data

debbie tries... to make it a mobile app

Myfirstmobilegame1.png Myfirstmobilegame2.png

  • result: had to reinstall OpenJDK. must add open scene. build is fine. but colours look washed out. why?

answer from trainer: mobile must use mobile shader, AR must use AR shader.

  • what i have learnt: cannot anyhowly just compile your desktop version as mobile version, have to redo all the shaders and interface and everything


Window > Rendering > Lighting Setting > can set different skybox environment and other overall lighting settings


Reflective / Metallic Shader

  • Can use reflection probe to calculate it.
  • A Reflection Probe is rather like a camera that captures a spherical view of its surroundings in all directions. The captured image is then stored as a Cubemap that can be used by objects with reflective materials.
  • Several reflection probes can be used in a given scene and objects can be set to use the cubemap produced by the nearest probe. The result is that the reflections on the object can change convincingly according to its environment.

Lesson 3 - Lighting and animation

Introduction to Game Lighting

  • The scene can look very different by just changing the light (number, placement, rotation, type of light) - use to create different feeling in the game

Examplelightinggames.png Examplelightinggames2.png

  • Using lighting to highlight elements to place certain things in focus and get dynamic effects
  • Using normal maps to create more surface detail for an object

Debbie's digression: how to create photoshop normal map

  • Open texture in Photoshop as you would normally any image. Image must be set to RGB.
  • Choose Filter > 3D > Generate Normal Map


Games vs film

  • Games lighting - baked (pre-enabled) and calculated real time, performance and number of lights depend on platform, ray-traced shadow may cause performance lag, but realtime global illumination is possible depending on platform used, all rendering is on one platform
  • Film lighting - completely rendered before showing, no platform dependent performance, ray-traced shadows used extensively, pre-calculated global illumination is widely used (even more realistic), rendering power can be distributed to renderfarm
  • Debbie wonders: why doesnt everyone just go and use realtime game lighting? It is because it has to be done on one platform, cannot be distributed to speed up the production.

Types of Lights in Unity

  • Spot Light
  • Directional Light
  • Point Light
  • Area Light - rectangular light used for baking only (WILL NOT SHOW IF NOT BAKED, unlike the rest of the lights) - governed by width and height, you probably won't use this unless lighting an interior design or something pretty fixed. Is used to fake certain glows.
  • Skybox

Objects in scene with overlapping UV

Overlappinguvalert.png Please see this webpage for more information about objects with overlapping UVs: https://docs.unity3d.com/Manual/ProgressiveLightmapper-UVOverlap.html

  • it happens when the overlap is WITHIN the same object - is 3d modelling issue not because you overlap 2 objects in a scene (if they are seperate object, they will not trigger)

Lightmap and Lighting

Hands-on: we added a spotlight and added it as a child to the hero player like a torch.

  • Lightmap format - EXR (Extended Dynamic Range) [OpenEXR]

Settingsforlight.png Lightmap1.png Lightmap3.png

This blue map is the baked light map which you can see under the lighting table > baked light map. On the right, it also breaks down all the cubes in the scene and shows the lighting map for that too.

How to solve: where to find the light gizmo and fixing light baking

Lightgizmo.png Lightbake.png

Two things to note:

  • if you cannot see the light ray, click on the "gizmo" so you have the handles to edit
  • if your light doesn't seem to move altho the gizmo is properly parented, you may have set the light to BAKED instead of realtime, it has to be realtime otherwise it is fake baked into the scene

How to solve: cut out light / cookie


How to solve: navigation issue lock and unlock rotation


  • Did your scene orbit view stop working? Check that this tiny padlock is not locked.

How to solve: shader transparency


  • Shader: You can make an object transparent using the alpha for the albedo. There is a value for A under RGB.

Recap of lighting

  • Changing the intensity of a light adjusts the BRIGHTNESS


  • Parallel light - will not be cast by skybox or point light or area light, only directional light - for more info read this: https://docs.unity3d.com/Manual/Lighting.html
  • SOFT shadow type casts shadows that approximate the natural fuzziness of real shadows due to emission area size and the bouncing of light. (As opposed to HARD shadow - hard shadow uses less cpu, but today soft shadow is most commonly used because NO MORE LIMITS)

Extra: Light Probe Group

  • Light Probe Group - what if I have a scene which is really realistic with a big red wall and I want the red colour light to bounce onto my user’s face? Baking all the information into a light probe group. If you put too many, it will impact on cpu. But if you put too little, there can be unintended lighting effects in realtime lighting.

Lightprobe1.png Lightprobe2.png Lightprobe3.png Lightprobe4.png

  • for a outdoor scene like PUBG you will not need so many, but for things like horror games where lighting is important and there are high contrast between lighting areas and objects, you need more light probe groups
  • Ideas: using theatre gobo (cutouts) [Hmm where does the word gobo come from anyway? Wikipedia says it is cited by some lighting professionals as "goes before optics" or, less often, "goes between optics". An alternative explanation is "graphical optical black out.]
  • If in blender i can use video for the light cutout within cycles nodes, what about in unity? (maybe is cpu heavy and not best practice tho)

Common lighting-related questions in Unity Cert Exam

  • selecting generate light map Uvs in the import setting of a model > will CREATE an additional set of UX coordinates for the light map data [it doesn’t generate] > see the occlusion
  • Occlusion is like a light map, generated by your 3d software > NEXT Question: how do I bake ambient occlusion (AO texture) for a model in blender?
  • to darken the ambient occlusion in baked lighting > increase the ambient occlusion amount (ambient occlusion is what you see in the corner of the room)
  • light probes are used to > SAMPLE baked lighting at specific points in the scene

Question: Light map or AO map?

Why do some things use lightmap and some use occlusion map?

  • Check out unity attic scene - 2019 is the light they really moved 2d lights forward
  • From poly count - https://polycount.com/discussion/79561/light-maps-and-ambient-occlusion-maps (this description helped me)
    • “Ambient Occlusion represents shadowing that comes from the environment itself, not from any particular lightsource. I like to think of it as the shadows being cast by bounced light, as opposed to the shadows being cast directly by a light.
    • A light map is baking any lighting information into a map. You could set up a bunch of lights, and then bake that into a texture to then use for whatever purposes.
    • A shadow map is when you bake only the shadows being cast. This is one way to get an Ambient Occlusion map, by baking a shadow from a light that simulates bounce light, like 3dsmax's Skylight. But you don't necessarily need a light to bake an AO. There are AO shaders, like Mental Ray's, which generate those shadows based on the objects in the scene.
    • At any case, the reason AO is so popular, is because it adds quite a bit of volume and depth to an object, without hinging on a lightsource. This is great for video-games, as stuff tends to move around, and the light direction can change. So if you bake really strong shadows that look like they're coming from above, and then in-game the light moves to the side of an object, or below it, it will look real weird. AO doesn't have that problem.
    • Baking a lightmap though, is something I never quite got the hang of. You basically set up a scene with some cool lighting, then bake that to use as an addition or a base in your texture.”
  • DD: Lightmaps seem so advanced today! Why not use all lightmap??? (unless cpu performance is impacted)

UI improvement

  • add playmode tint to unity


Animation 101

  • Animation is vital in game dev - can animate different things - characters / environment objects
  • Import animation from external software like maya, 3ds max, blender, etc


Animating Object

  • hands on in the class: Prefab folder > Knightsgame > item_gift01 > drag to scene
  • put the box collider on the parent object
  • DO NOT PUT THE ANIMATOR ON THE PARENT OBJECT > Add component to the child object inside (in this case, mod_gift_red)
  • So you add animator component to the child
  • Window > Animation > Opens up the animation tab
  • Click on tiny 3 dot button on right and "show samples
  • Change samples to 30fps
  • Click on the red record button
  • Keyframing (similar to blender)
  • Can adjust curves for easing





Curves are automatically applied in unity. If you want to make linear - Rotating objects - set BOTH TANGENTS to linear


  • Animator Window > see the different states

Unityanimator 1.png Unityanimator 2.png

  • eg: upon entry > go to idle > from any state it can go to the forward animation or the skill animation

Animation: Transition Parameters

  • float -
  • integer -
  • boolean - true or false
  • trigger - fire and forget (if you touch something, triggered) - rather than a boolean that stays true and false until reset back by a script, a trigger happens, is consumed, and then is reset
  • create "Die" Parameter (be careful about casing must be Die)
  • Example file - knights_skill spinning > highlight the skill arrow > under conditions in inspector, set to Die

Unityanimator parameters1.png

Lesson 4 - Intro Scripting in Game Dev

Scripting 101

  • To build custom behaviour for custom game assets - applied as components to gameobjects
  • They can have behaviours, properties and variables which we can manipulate to make them behave the way that we want

Basic Structure

  • MonoBehaviour is the base class from which every Unity script derives
  • Example of default script (C#) in Unity:
using UnityEngine;
using System.Collections; // namespace

public class MyAwesomeScript : MonoBehaviour { // classname must be same as file name
	// use this for initialisation
	//run once at the start of the method
	void Start () {


	//update is called once per frame (60 times in one sec)
	//used commonly for detecting input by the player like collisions etc
	void Update () {


these are pre-created in unity as a basic structure


EnemyToPlayer.cs - works

  • Let's say you are going to write a script for your Player - go to prefab folder > look for monster black cube > drag him into scene
  • Right-Click on Scripts folder > Create new C# script > create one called EnemyToPlayer
//using System.Collections;
//using System.Collections.Generic;
using UnityEngine; //namespace
using UnityEngine.AI;

public class EnemyToPlayer : MonoBehaviour
	// reference player position so that enemy can follow player
	private Transform goal;//data can be private or public if you want other script to access it

	// reference to enemy's navmesh agent
	private NavMeshAgent enemy;

    // Start is called before the first frame update
    void Start()
     	// find the navmeshagent component on enemy's gameobject
     	enemy = GetComponent<NavMeshAgent>();

     	// find the player gameobject and define player's transofmr as enemy's goal/destination   
     	goal = GameObject.Find("Hero_01_Knight").transform;

     	// tell enemy to go to goal transform position x y z 
     	enemy.destination = goal.position;

    // Update is called once per frame
    void Update()
  • Add navmeshagent component to the enemy. if you do not add it in, it will have error saying you must add navmeshagent
  • change the angular speed to 2000 and acceleration to 20
  • make sure the correct script has no errors (fix compiler error)
  • Now your enemy will follow your player!

How to solve: global namespace error

  • if you get the error "The namespace `global::' already contains a definition for xxx" - you may want to check that you haven't got a doubled file somewhere in your project. Check the project files for duplicates!


Common error: class name

User fails to name the class correctly - it is class NewBehaviourScript instead of the name of your actual class. WHen you create a script in unity, the first name you assign it will be named as the class. If you press ENTER too early and just rename the file, the class will not be autonamed for you.

PlayerHit.cs - works

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerHit : MonoBehaviour

	// reference to Animator component
	private Animator KnightModelAnimator;

    // Start is called before the first frame update
    void Start()
        //find the gameObject Mod_Knight_New and get component
        KnightModelAnimator = GameObject.Find("Hero_01_Knight/Mod_Knight_New").GetComponent<Animator>();

    // Update is called once per frame
    void Update()
	// if player collides with object
    void OnTriggerEnter (Collider other) 
    	// if the other object is tagged as "Enemy"
    	if (other.gameObject.tag == "Enemy")
    	// then player will play the "Die" animation via Animator Component
  • Make sure box collider for monster has "Is Trigger"
  • Note how the box collider is smaller than the monster itself (a light green box)
  • Increase size of box collider to 1 x 1 x 1 (bigger)

Boxcolliderenemy.png Boxcolliderenemy2.png

  • Create tags Enemy, Boss, GiftPet, GiftShield


  • Add tag to monster "Enemy"
  • Add tag to giftbox
  • must add rigidbody to enemy for collider to work - untick use gravity, tick is kinematic
  • Top tip: don't make the collider too exact

Common errors in the class

  • excess curly brackets which are not under any method
  • gameObject or GameObject - it doesn't matter

Methods: what does 'void' mean?

  • void - it does not return / it goes into the void
  • return - it returns a value at the end
public void getName(){
 return name;

so for example: this is WRONG - a void method does not return

Lesson 5 - navigation / pathfinding / player allies enemies

Lesson 6 - Particle Systems

Lesson 7 - audio, camera, player selection, system, user interface

Lesson 8 - building and prepping for mobile deploy

Certification Exam

  • 100 questions pulled randomly from a bank - mcq, drag and drop, matching, hotspot
  • 90 mins to complete
  • must score 70% to earn Unity Certified Developer
  • Unity Exam shortcut section - based on PC

Beyond Unity

  • Unity isn't the game for every sort of game. Can also consider Cocos-2dx.