Introduction to Unity
-
Upload
petri-lankoski -
Category
Documents
-
view
2.386 -
download
0
description
Transcript of Introduction to Unity
Petri Lankoski, [email protected]
Introduction to UnityFor Unity 3.5
Petri Lankoski, [email protected]
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, [email protected]
Importing a PackageDownload:
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/escape.unitypackage.zip
Unzip the downloaded file
Assets -> Import Package -> Custom Package… Select the downloaded package
Petri Lankoski, [email protected]
Anatomy of Unity GUIProject Frame contains assets and scripts• We got these from packages• These are your tools to
build the game
Petri Lankoski, [email protected]
Anatomy of Unity GUIScene & Hierarchy views• View to your level (game)• For building a level
Petri Lankoski, [email protected]
Adding a Plain
Petri Lankoski, [email protected]
Anatomy of Unity GUI
Inspector• Shows details of the
selected object
Petri Lankoski, [email protected]
Modifying the PlainChange X and Z to 20• Experiment
to find suitable scale
• Y should be 1Drag-and-drop
ground to plain
These should be0
Petri Lankoski, [email protected]
Navigating in Unity
Hand tool (shortcut: Q)- click-drag to move camera- ALT click-drag to orbit camera around- CTR click-drag to zoom
Move tool (shortcut: W)
Rotate tool (shortcut: E)
Scale tool (shortcut: R)
On scene view:• F to zoom to selected object• Hold right mouse to enable• ASWD movement• Q up, E down
Play Mode
Petri Lankoski, [email protected]
Directional Light
Move by Drag fromAn arrow
Rotate by Drag fromThe sphere
Petri Lankoski, [email protected]
Player PrefabMake sure thatObject is on the plain• Set to
0,0,0
Drag up until the object is totally visible
Petri Lankoski, [email protected]
Adding Manager Rename the empty object
as GameManager
Drag-and-drop GameAgents on GameManager
Petri Lankoski, [email protected]
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, [email protected]
Connecting Waypoints
1. Drag and drop Waypoint2 to NextTarget on Waypoint1
2. Drag and drop Waypoint3 to NextTarget on Waypoint2
3. …
Petri Lankoski, [email protected]
Time to Test
Petri Lankoski, [email protected]
Adding Things Walls:
Hierarchy: Create -> Cube
Scale & Rotate & Move
More complex objects are modeled in separate software.
Petri Lankoski, [email protected]
New Objects from MayaCreate 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, [email protected]
New TexturesCreate 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, [email protected]
Renderer & MaterialsAn 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, [email protected]
Material
Shader
This part changes based on the selected shader
Preview
Petri Lankoski, [email protected]
Prefabs In Escape Package
Petri Lankoski, [email protected]
EnemyCollider• For
moving objects
Plays sounds
Enemy logic• Movement
speed• Damage
dealt• Sound files
Checkbox for Enabling/disablingscripts
Petri Lankoski, [email protected]
Enemy
Tag is used withwaypoints• Different tags
ensure that enemies keep their tracks
Petri Lankoski, [email protected]
Enemy Components / Billboard
Enemy consists of multiple billboards• Texture
animation• Textures• Animations
speed
Petri Lankoski, [email protected]
Enemy Components / Light
Petri Lankoski, [email protected]
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 collide with it
Petri Lankoski, [email protected]
Door
Player reached the end if this is checked
These controls how completing the game is shown
Petri Lankoski, [email protected]
Door
The name of level where the door leads• If multiple
names are provided, one is selected randomly
Levels needs to be in Scenes in Build!
Petri Lankoski, [email protected]
Door with Lock
Petri Lankoski, [email protected]
Player Start Waypoint Player object only to the
first level
In levels 1- Place PlayerStart where
the player object begins
Petri Lankoski, [email protected]
Scenes (levels) Level 0
Splash screen Very minimal to
Levels 1+ Actual game levels
Petri Lankoski, [email protected]
Setting up Start ScreenFile -> New Scene
Download package: http://dl.dropbox.com/u/1380179/
escape_mainmenu.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, [email protected]
Start Screen
Build Game
Petri Lankoski, [email protected]
Select target and build
Select: • File -> Build Settings…
Alternatively:• File -> Build Settings…