Game Development with Unity3D
Inside/Outside Unity3D
Yingcai Xiao
Unity3D
Engine
IDE
Assets
Tutorial
Examples
Installation
Download at
https://education.github.com/pack
Unity.com/
Supporting multi-platforms.
Unity 3D: Create Project
•Create your first Unity3D project.
Getting started with a simple Unity3D project
Start Unity3D
Basic Components: Game Objects, Prefabs,
Physics and Scripting
File->New Project (3D or 2D)
File->Save Scene
Getting started with a simple Unity3D project
EDP-Unity5
EDP.sln
GUID: Globally Unique ID
based on time, MAC ID, no-reentrant.
Getting started with a simple Unity3D
project
Assets->Import Packages
- Cameras
- Characters
- Effects
- Environment
- ParticleSystems
- Utility
- Vehicles
Object Creation
GameObject->3D object->sphere
Edit->Frame Select (to show the created object)
Hold onto the arrows to move the sphere or change
the position in the Inspector.
Note: Y is up.
Inspector and transform panel
Moving, translation, rotation and scaling tools
Unity 3D: Component
Select the created Game Object, then
Component->Physics->Rigidbody
• Rigid Objects: non-deformable with physical properties
(gravity, inertial).
• Non-rigid Objects:
• Deformable: changeable geometry
• Breakable: changeable topology.
• Intangible Objects: No predefined shape.
fire, clouds, …
Animation
Window-
>Animation
Click on the object
to be animated.
Component-
>Miscellaneous-
>Animation
Animation
In the Animation window:
Create New Animation Clip
Click on the record button (red) at the top-left.
Save the new animation clip file.
Click on Curves.
Select Add Property->Transform (click on the arrow)
position,
Animation
Click on the top of the timeline to start a new key point.
Move the object in the Scene up.
Click on the top of the timeline to start another key
point.
Move the object in the Scene to the right.
Now click on the play button in the Animation window.
Animation
Add key frame on the timeline as many as you want.
Click on the red button again to finish making the
animation clip.
Animation (Unity5)
You can switch from the default “Dopesheet” view to
“Curves” view and drag the curves to modify the animation.
Animation
Go back to Unity window.
Under Inspector Animation , change the
name of animation clip from none to the
one that you have made.
Play Animation
Back to the Unity Main Window.
Click on the play button.
What happened?
The object dropped out after the animation.
Go to the Inspector, remove the “Rigid Body”
component.
Play again.
Animation Event
Allows you to call functions in the object’s
script at specified points in the timeline.
Add a new Animation Event by double-
clicking the Event Line or by using the
Event button.
Animation Event
When you add an event, a dialog box will
appear to prompt you for the name of the
function and the value of the parameter you
want to pass to it.
Unity 3D: Light
• Game Object ->Light -> Directional Light (Default)
• Move and rotate just like any other object.
Terrain
• GameObject 3D Object Terrain
• In the hierarchy panel, select Terrain.
• In the Inspector: set position x = -5, y = 0, z = -5.
• Click on one of the action icons in Terrain (Script) to
raise/lower terrain, paint height, smooth height, paint
texture, place trees, paint details, terrain setting. Adjust
brush size to 1 before performing the operations.
Terrain
• Assets->Import Package->Environment
• In Inspector of the Terrain
• Select Brush Texture
• Edit Texture
• In the “Add Terrain Texture” Window, click on “Select”
• Select GrassFrond in the “Select Texture2D” window
• Click on “Add” in the “Add Terrain Texture” Window
Trees
There are two ways to place trees:
creat individual trees
brush forests
Create an individual tree
Game Object->3D object ->Tree
In the Inspector, add brunches and leaves
Trees
Brushing forests:
In Hierarchy, select the terrain object.
In Inspector->Edit Trees -> Add Trees
In Add Trees popup window, click on the little circle at the
right-most of the “Tree Prefab” row.
Select, say, Palm and then click on “Add”
Go back to Inspector, in Terrian area, click on
“Place Trees” button
Brush trees in the Scene window.
Physics
Unity3D provide Physics library.
- Rigidbody, collider, joint, force and etc.
Rigidbody component : gravity automatically added
Collision detection : box, sphere, capsule , mesh, and terrain.
Collision call back function : OnCollisionEnter,
OnCollision and OnCollisionExit.
Player (for a third-person game)
• Make sure to save the scene “File->Save Scene”
(Ctrl S”) and save the project
“File->Save Project”
• Assets->Import Package->Characters
• In the Project window, drag “Assets->Standard
Assets->Characters->3rd Person Character->Prefabs-
>3rdPersonController.”
to the Hierarchy window or directly into the Scene.
• In the Hierarchy window, double-click on the 3 rd
Person Controller.
• Click on the “Move selected object” icon. Then
move the controller to the top of the terrain. You may
have to adjust your view angle by clicking on the
‘xyz” icon to see the position. Click the middle of
the icon to get the perspective view.
Unity 3D: Play
• Now click on the “Play” icon and use
the arrow keys to controll the player.
• You should see the player running
around and make sure he does not run
off the edge.
Unity 3D: Build
• File->Build Setting
• Can build games for more than ten
platforms (including Windows, iOS,
Linux, WebGL, almost all game
consoles.)
• WebGL:
https://docs.unity3d.com/Manual/webgl-
building.html
Under the Hood
Unity 3D IDE
IDE: Integrated Development Environment
Project: directory and files for a specific
game project.
C:\Users\xiao\Documents\New Unity
Project 1
\Assets (anything you can reuse)
\Library (binary files)
Unity 3D: Assets
C:\Users\xiao\Documents\New Unity
Project 1\Assets (anything you can reuse)
\Standard Assets
\OpenNI
\Scripts
\_Scenes
\Materials
\Artwork
Unity 3D: Standard Assets
C:\Users\xiao\Documents\New Unity Project 1\
Assets\Standard Assets
Objects: (Look)
\Tree
\Terrain
\Charater
Lights: (Look)
\Light Flares
\Light Cookies
Code: (Feel: control, interaction, animation, …)
\Scripts
Unity 3D: Objects
C:\Users\xiao\Documents\New Unity Project 1\
Assets\Standard Assets\Charater:
Prefab: (Predefined Objects)
First Person, 3rd Person
\Source:
\Prototype (Look)
Constructor.FBX
\Materials (properties)
\Textures (images)
\Scripts (Feel: actions)
Java Scripts: ThirdPersonController.js
C#: MouseLook.cs
Unity 3D: Scripts
Languages:
Interpreted : Java Script (no more)
Compiled: C#
Usages:
General: under Project\Scripts
ExitOnEscape.cs
Objects: attached to objects
ThirdPersonController.js
Unity 3D: Library
cache:
for speeding up processing
metadata:
data that describes data
previews:
for previewing scenes
ScriptAssemblies:
compiled object assemblies for scripts
Resources for 3D model
http://www.turbosquid.com
Blender
http://www.blender.org
Autodesk Maya
http://www.autodesk.com/products/autode
sk-maya/overview
Unity
• A popular game engine
• An IDE for developing application of
interactive animations.
• Support drag-and-drop visual
programming
• Abundant importable assets.
• Can be built for many game systems.