My teaching materials for introducing Unity. There are related Unity Packages containing prefabs, assets, and scrips used. Updated slides 2013/01/07 to reflect the location of the packages.
2. New Project
File -> New Project…
Set name and directory
where you want to store the
project
Select
Image Effect (ONLY IF
YOU HAVE Pro)
Toon Shading
Petri Lankoski, petri.lankoski@sh.se
3. Importing a Package
Download:
If you have free version:
http://www.mediafire.com/file/2bdmrn5j4vcikpa/
escape_stripped.unitypackage.zip
If you have Pro
http://www.mediafire.com/file/y5i38txo42fj8i3/esc
ape.unitypackage.zip
Unzip the downloaded file
Assets -> Import Package -> Custom Package…
Select the downloaded package
Petri Lankoski, petri.lankoski@sh.se
4. Anatomy of Unity GUI
Project Frame contains assets
and scripts
• We got these from packages
• These are your tools to build
the game
Petri Lankoski, petri.lankoski@sh.se
5. Anatomy of Unity GUI
Scene & Hierarchy views
• View to your level (game)
• For building a level
Petri Lankoski, petri.lankoski@sh.se
6. Building a scene
Delete Main Camera
Petri Lankoski, petri.lankoski@sh.se
8. Anatomy of Unity GUI
Inspector
• Shows details of the
selected object
Petri Lankoski, petri.lankoski@sh.se
9. Modifying the Plain
Change X and
These should be Z to 20
0 • Experiment
to find
suitable
scale
• Y should be
Drag-and-drop 1
ground to plain
Petri Lankoski, petri.lankoski@sh.se
10. Navigating in Unity
Move tool (shortcut: W)
Play Mode
Rotate tool (shortcut: E)
Scale tool (shortcut: R)
Hand tool (shortcut: Q) On scene view:
- click-drag to move camera • F to zoom to selected
- ALT click-drag to orbit object
camera around • Hold right mouse to enable
- CTR click-drag to zoom • ASWD movement
Petri Lankoski, petri.lankoski@sh.se • Q up, E down
11. Save a Scene
File -> Save Scene
Name it “First”
Or something else
Petri Lankoski, petri.lankoski@sh.se
12. Player & Light Source
Drag-and-drop
Player
Petri Lankoski, petri.lankoski@sh.se
13. Directional Light
Move by Rotate by
Drag from Drag from
An arrow The sphere
Petri Lankoski, petri.lankoski@sh.se
14. Player Prefab
Make sure
that
Object is on
the plain
• Set to 0,0,0
Drag up until
the object is
totally visible
Petri Lankoski, petri.lankoski@sh.se
15. Adding Manager
Rename the empty object
as GameManager
Drag-and-drop
GameAgents on
GameManager
Petri Lankoski, petri.lankoski@sh.se
16. Time to Test
Hit Play
Petri Lankoski, petri.lankoski@sh.se
17. Adding Waypoints for an
Enemy
Drag and drop
four Waypoint to
scene
• Place them to
corners (as in
Figure)
• Make sure
that
Waypoints are
on top of the
plain
Petri Lankoski, petri.lankoski@sh.se
18. Grouping Objects in Hierarchy
Rename waypoints Grouping Object
Petri Lankoski, petri.lankoski@sh.se
19. Connecting Waypoints
1. Drag and
drop
Waypoint2 to
NextTarget on
Waypoint1
2. Drag and
drop
Waypoint3 to
NextTarget on
Waypoint2
3. …
Petri Lankoski, petri.lankoski@sh.se
23. Adding Things
Walls:
Hierarchy: Create ->
Cube
Scale & Rotate & Move
More complex objects are
modeled in separate
software.
Petri Lankoski, petri.lankoski@sh.se
24. New Objects from Maya
Create an object in Maya
Save (ma/mb)
Maya needed on the machine running Unity
Export FBX
Move the model to Assets folder
Set import scale
Do not use Transform – Scale on Inspector with
imported models to change the default scale
Petri Lankoski, petri.lankoski@sh.se
25. New Textures
Create a texture in Photoshop
Preferred size: n2 x m2
Default max size of a texture: 1024x1024
Bigger textures consumes more memory
Use psd or tiff formata
Keep layers
Save it to Assets folder
Open Unity
Petri Lankoski, petri.lankoski@sh.se
26. Renderer & Materials
An object has renderer
Renderer draws the object to the screen
Renderer has one or materials
Materials consists of
Shader
Resources that the shader needs for rendering
E.g., textures, colors, other assets
Multiple objects can share a material
If the material is changed, the rendering of all
objects having that material is changed.
Petri Lankoski, petri.lankoski@sh.se
27. Material
Shader
This part
changes
based on the
selected
shader
Preview
Petri Lankoski, petri.lankoski@sh.se
28. Prefabs
In Escape Package
Petri Lankoski, petri.lankoski@sh.se
29. Checkbox for
Enabling/disabling
Enemy scripts
Collider
• For moving
objects
Plays sounds
Enemy logic
• Movement
speed
• Damage
dealt
• Sound files
Petri Lankoski, petri.lankoski@sh.se
36. Waypoints
This should match
to Tag of an
enemy
• Default ok if
you do not
have crossing
tracks
Waypoint has a
collider
• Place it so that
an enemy can
Petri Lankoski, petri.lankoski@sh.se collide with it
37. Door
Player reached
the end if this is
checked
These controls
how
completing the
game is shown
Petri Lankoski, petri.lankoski@sh.se
38. Door
The name of level
where the door
leads
• If multiple
names are
Levels needs to be provided, one
in Scenes in Build! is selected
randomly
Petri Lankoski, petri.lankoski@sh.se
40. Player Start Waypoint
Player object only to the first
level
In levels 1-
Place PlayerStart where
the player object begins
Petri Lankoski, petri.lankoski@sh.se
41. Scenes (levels)
Level 0
Splash screen
Very minimal to
Levels 1+
Actual game levels
Petri Lankoski, petri.lankoski@sh.se
42. Setting up Start Screen
File -> New Scene
Download package:
http://dl.dropbox.com/u/1380179/escape_mainmen
u.unitypackage
Assets -> Import Package -> Custom Package…
Select escape_mainmenu.unitypackage
Add Player prefab to scene
This is the only level where Player should be!
You can add the Player for testing
Remove after level is ready
Petri Lankoski, petri.lankoski@sh.se
43. Escape Splash Screen
Drag-and-drop
Draws the GUI
Petri Lankoski, petri.lankoski@sh.se
44. Setting up Start Screen
Write the
name of
your first
level
Petri Lankoski, petri.lankoski@sh.se
45. GUI Skin
Changes how
buttons and
labels look like
Petri Lankoski, petri.lankoski@sh.se