Unity Course Notes

From Wikicliki
Revision as of 04:25, 12 September 2020 by WikiSysop (talk | contribs) (Lesson 3 - Lighting and animation)

Jump to: navigation, search

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

Contents

Lesson 1 - Welcome to Unity Certified Developer Courseware

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

Unityhublts.png

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

Unityunity.png

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

Unityjobroles.png

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

Unityinterfaceorgsuggested.png

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

Creating Game Object

Creategameobject.png

Child & Parent Objects

Creategameobjectchild.png

Tagging

Tagginggameobject.png

  • 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

Importzombie.png

GameObject Settings

Linkspritesheet.png

Transform (moving)

You can be precise about the position you move in Inspector

Transformunity.png

Importing Packages the right way

Importcustom.png

  • 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

Navigation

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

Createsceneandbakenavigation.png

  • 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)

Basicgamenityplatform.gif

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"

Rigidbody

Rigidbodyunity.png

Raycast

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

Shaders

Shaderunity.png

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

Cutout

Unitycutout.png

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

Cookie

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

Skybox

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

Lightingunityskybox.png

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

Photoshopgeneratenormals1.png


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

Cookielightunity.png

How to solve: navigation issue lock and unlock rotation

Lockview.png

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

How to solve: shader transparency

Transparencyobjectunity.png

  • 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

Directionallightexample.png

  • 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: “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.”

Lesson 4 - Intro Scripting in Game Dev

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.