SlideShare ist ein Scribd-Unternehmen logo
1 von 95
Downloaden Sie, um offline zu lesen
Game Development
Grundlagen der Unity-Engine
Nick PrĂźhs
About Me
“Best Bachelor“ Computer Science
Kiel University, 2009
Master Games
Hamburg University of Applied Sciences, 2011
Lead Programmer
Daedalic Entertainment, 2011-2012
Co-Founder
slash games, 2013
Microsoft MVP
2015
2 / 12
First Things First
• At npruehs.de/teaching you‘ll find all slides
• Ask your questions – any time!
• Contact me any time at dev@npruehs.de!
3 / 12
Objectives
• To understand the fundamentals of game lifecycles
• To learn how to build a small game with Unity3D
• To get an idea of how to learn from others
4 / 60
New Unity Project
5 / 12
New Unity Project
Unity projects contain
multiple different
files and folders
• Assets (3D Models,
Images, Code)
• Settings (Input,
Phyiscs)
• Temporary Files
(imported assets,
see later)
6 / 12
Unity Editor Layout – 2 by 3
7 / 12
Unity Editor Layout – 2 by 3
The scene view shows
all objects of the level
and allows free
movement.
8 / 12
Unity Editor Layout – 2 by 3
The game view shows
the level as seen by
the camera.
9 / 12
Unity Editor Layout – 2 by 3
The hierarchy
provides an overview
of all scene objects.
10 / 12
Unity Editor Layout – 2 by 3
The project view
contains all assets (3D
models, code) of your
project.
11 / 12
Unity Editor Layout – 2 by 3
The inspector shows
the details of the
selected game object.
12 / 12
Unity Camera
13 / 12
The camera draws
scene objects as seen
from its position.
Asset Import
Unity imports all of
your assets so it
understands how to
use them properly.
(Thanks, Unity!)
14 / 12
Asset Import
Unity imports all of
your assets so it
understands how to
use them properly.
(Thanks, Unity!)
15 / 12
Game Loop
Update
Draw
16
Init Shutdown
The game lifecycle is split up into four major steps.
Game Loop
Update
Draw
17
Init Shutdown
During initialization, the game sets up everything to run properly, such
as preparing the graphics device, loading all assets, or opening a log file.
Game Loop
Update
Draw
18
Init Shutdown
In each update, all game objects may change their properties, such as
position, health, or cooldown timer.
Game Loop
Update
Draw
19
Init Shutdown
Then, the game tells the graphics device what to draw, where, and how.
Game Loop
Update
Draw
20
Init Shutdown
Finally, the game needs to shut down properly, returning the graphics
device to the operating system, for example.
Our First Script!
Now that we’ve got our little space ship ready, it’s
time to add some action!
We want to do two things now:
1. Check if the player pressed a button.
2. Move the space ship if he or she did.
21 / 12
Our First Script!
22 / 12
In Unity, we can
attach scripts to
game objects.
Each script will
describe the behavior
of that particular
game object.
Our First Script!
C#
23
// Use the magic code Unity provides for us.
using UnityEngine;
using System.Collections;
// Name of the script.
public class KeyboardMovement : MonoBehaviour
{
// Use this for initialization.
void Start ()
{
// Nothing to do here, yay!
}
// Update is called once per frame.
void Update ()
{
// Check if player pressed any button.
if (Input.GetKey(KeyCode.W))
{
// Add "forward" vector to current position.
this.transform.localPosition += Vector3.forward;
}
}
}
Our First Script!
// Use the magic code Unity provides for us.
using UnityEngine;
using System.Collections;
Whew, that’s a lot of
stuff. Let’s take a detailed
look at that!
First, game engines like
Unity and frameworks
like .NET save us from
writing the same code
over and over again (e.g.
vector math, lists).
24 / 12
Our First Script!
// Name of the script.
public class KeyboardMovement:MonoBehaviour
{
…
}
Clearly, Unity needs to
know the name of our
script.
The other stuff (public,
class, MonoBehaviour,
that strange colon, …)
won’t be covered here.
Go to a dedicated
computer science class
for that ;)
25 / 12
Our First Script!
// Use this for initialization.
void Start ()
{
// Nothing to do here, yay!
}
26 / 12
Remember the
initialization we
sometimes need to do
before entering the game
loop?
Unity allows us to that
right here, right now!
Our First Script!
// Use this for initialization.
void Start ()
{
// Nothing to do here, yay!
}
Remember the
initialization we
sometimes need to do
before entering the game
loop?
Unity allows us to that
right here, right now!
(Thanks, Unity!)
27 / 12
Our First Script!
// Check if player pressed any button.
if (Input.GetKey(KeyCode.W))
{
…
}
Unity even intercepts
keyboard input for us.
All we need to do is
ask ;)
28 / 12
Our First Script!
// Add "forward" vector to current position.
this.transform.localPosition += Vector3.forward;
Unity stores
information relevant
for drawing the scene
with our camera in a
transform.
This includes the
position of an object,
its rotation, and its
scale.
29 / 12
Vector Math
Think of vectors as sets of coordinates in our
coordinate system:
𝑣 =
𝑥
𝑦
𝑧
30 / 12
Vector Math
Just as numbers, you can add vectors, resulting in a
new set of numbers:
𝑣1 + 𝑣2 =
𝑥1
𝑦1
𝑧1
+
𝑥2
𝑦2
𝑧2
=
𝑥1 + 𝑥2
𝑦1 + 𝑦2
𝑧1 + 𝑧2
31 / 12
Vector Math
Just as numbers, you can add vectors, resulting in a
new set of numbers:
𝑣1 + 𝑣2 =
1
2
3
+
4
5
6
=
5
7
9
32 / 12
Our First Script!
// Add "forward" vector to current position.
this.transform.localPosition += Vector3.forward;
We can access the
transform of the game
object the script is
attached to using the
this keyword.
Then, we can modify
its position by using
the += operator.
33 / 12
Our First Script!
Whew, that was fast!
Maybe we should improve our code here a bit.
1. Our spaceship should have its own speed value.
This will also allow us to have different ships with
different speed!
2. We should take the frame time of our game into
account. Otherwise, our spaceship would be
faster if our PC is faster – unfair!
34 / 12
Our First Script!
C#
35
// Use the magic code Unity provides for us.
using UnityEngine;
using System.Collections;
// Name of the script.
public class KeyboardMovement : MonoBehaviour
{
// Speed of this game object.
public float Speed;
// Use this for initialization.
void Start ()
{
// Nothing to do here, yay!
}
// Update is called once per frame.
void Update ()
{
// Check if player pressed any button.
if (Input.GetKey(KeyCode.W))
{
// Add "forward" vector to current position.
this.transform.localPosition += Vector3.forward * this.Speed * Time.deltaTime;
}
}
}
Our First Script!
// Speed of this game object.
public float Speed;
Here, speed is a
variable (like x in your
math class).
public means,
everybody can change
the speed value.
float means, speed
may be a fraction (like
1.4)
36 / 12
Our First Script!
37 / 12
Unity exposes public
variables in the
inspector we were
talking about earlier.
Change the speed
value and see what
happens!
A Nice Space Background
Lets pick up a nice space
image from the official
NASA website:
http://apod.nasa.gov/ap
od/ap120828.html
38
A Nice Space Background
Now, let’s change the
texture import settings of
our background:
Set Wrap Mode to Clamp.
39
A Nice Space Background
Next, we need to create a
material for the skybox to
use with our camera.
• Set the shader to
Skybox/6 Sided.
• Assign the texture to all
six slots.
40
A Nice Space Background
Finally, we can change
the scene lighting
settings to use our
brand-new skybox!
41
Let’s make a side-scroller!
Just change the
position and rotation
of your camera –
easy!
42 / 12
Let’s make a side-scroller!
You can also reduce
the field of view to
ensure the skybox
looks nice.
43 / 12
Adjusted Movement
C#
44
// Update is called once per frame.
void Update ()
{
// Check if player pressed any button.
if (Input.GetKey(KeyCode.W))
{
// Add “up" vector to current position.
this.transform.localPosition += Vector3.up * this.Speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.S))
{
// Add “down" vector to current position.
this.transform.localPosition += Vector3.down * this.Speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.A))
{
// Add “back" vector to current position.
this.transform.localPosition += Vector3.back * this.Speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.D))
{
// Add "forward" vector to current position.
this.transform.localPosition += Vector3.forward * this.Speed * Time.deltaTime;
}
}
Now for some real action!
We want our spaceship to fire its weapons!
For this, we need to:
1. Add a projectile to our project.
2. Create a projectile whenever the player presses a
button.
45 / 12
Unity Prefabs
46 / 12
Unity allows us to
create prefabs of our
game objects.
Think of prefabs as
“Schablonen” for new
game objects.
Our Second Script!
C#
47
// Use the magic code Unity provides for us.
using UnityEngine;
using System.Collections;
// Name of the script.
public class KeyboardFire : MonoBehaviour
{
// Prefab to use as projectile.
public GameObject ProjectilePrefab;
// Use this for initialization
void Start ()
{
// Still nothing to do, yay!
}
// Update is called once per frame
void Update ()
{
// Check if player pressed the SPACE button.
if (Input.GetKey(KeyCode.Space))
{
// Fire projectile!
Instantiate(this.ProjectilePrefab, this.transform.position, this.transform.rotation);
}
}
}
Boring projectiles are boring
C#
48
// Use the magic code Unity provides for us.
using UnityEngine;
using System.Collections;
// Name of the script.
public class AutomaticMovement : MonoBehaviour
{
// Speed of this game object.
public float Speed;
// Update is called once per frame
void Update ()
{
// Fly "forward" automatically.
this.transform.localPosition += Vector3.forward * this.Speed * Time.deltaTime;
}
}
Hint
Splitting up your code across
multiple components is always a
better idea than writing huge,
monolithic code files!
49 / 61
Game Objects
• objects in your game world can (or cannot)…
• be visible
• move around
• attack
• explode
• be targeted
• become selected
• follow a path
• common across all genres
50 / 57
Game Objects
51 / 57
There are probably hundreds of ways…
Then one day your designer says that they want a
new type of “alien” asteroid that acts just like a heat
seeking missile, except it’s still an asteroid.”
- Scott Bilas
52 / 57
53 / 12
Camera Movement
54 / 12
Right now, we can easily
leave the screen, if we want
to.
Let’s change that:
1. Reparent the camera
to our player ship.
2. Add the automatic
movement script to the
player ship.
Unity Hierarchy
55 / 12
If a game object in
Unity is a child of
another, its transform
is relative to the one
of its parent:
• Position
• Rotation
• Scale
Adding Enemies
Time to add our first enemies!
We need to …
1. Create a prefab for our enemy space ship.
2. Rotate enemies correctly.
3. Modify their movement.
56 / 12
Automated Movement
With Direction
C#
57
// Use the magic code Unity provides for us.
using UnityEngine;
using System.Collections;
// Name of the script.
public class AutomaticMovement : MonoBehaviour
{
// Velocity of this game object.
public Vector3 Velocity;
// Update is called once per frame
void Update ()
{
// Fly "forward" automatically.
this.transform.localPosition += this.Velocity * Time.deltaTime;
}
}
Adding Enemies
58
Taking Damage
Next, we want to keep track of the health value of
each ship. After all, we want to destroy our enemies,
don’t we?
We need to:
1. Write a script keeping track of spaceship health.
2. Check for collisions of projectiles with ships.
3. Reduce health when projectiles hit ships.
59 / 12
Spaceship Health
C#
60
// Use the magic code Unity provides for us.
using UnityEngine;
using System.Collections;
// Name of the script.
public class Health : MonoBehaviour
{
// Health of this game object.
public float CurrentHealth;
// Update is called once per frame
void Update ()
{
// Destroy when dead.
if (this.CurrentHealth <= 0)
{
Destroy (this.gameObject);
}
}
}
Hint
The if operator in C# allows us to
add conditions to our code.
It’s always a good idea not to
compare numbers for exact values
(<= instead of ==)
61 / 12
Handling Collisions
As you can imagine,
finding out whether
two objects collide can
include some terrible
math.
In Unity, colliders can
be used to approximate
the extents of a game
object for easier
collision detection.
62 / 12
Handling Collisions
Let’s add a sphere
collider for our space
ship and projectiles!
63 / 12
Handling Collisions
If your collider moves
(just like our ships and
projectiles), we need to
add a rigidbody as well.
Make sure to disable
“Use Gravity”, or Unity
will make our
spaceships fall down.
64 / 12
Handling Collisions
Whenever two
objects collide, Unity
won’t allow them to
intersect each other.
Check “Is Trigger” to
allow these objects to
intersect!
65 / 12
Handling Collisions
C#
66
// Use the magic code Unity provides for us.
using UnityEngine;
using System.Collections;
// Name of the script.
public class DamageOnCollision : MonoBehaviour
{
// Damage this game object deals on collision.
public float Damage;
// OnCollisionEnter is called whenever we collide with somebody else.
void OnTriggerEnter(Collider other)
{
// Get the health component of the other object.
Health health = other.gameObject.GetComponent<Health> ();
if (health != null)
{
// Reduce health.
health.CurrentHealth -= this.Damage;
// Destroy this game object.
Destroy (this.gameObject);
}
}
}
Finishing Touches
67 / 12
Now, your job as
programmer is done
– time for the
designer in you!
Add enemies to the
level any play, play,
play!
Building The Game
68 / 12
Finally, we can build our
game, to show everyone
and share the fun 
Where To Go From Here
As with every software
project, there’s always more
to do…
• Enemy Fire
• Enemy AI
• Menus
• Explosions
• Score
• Cheats
• More Enemies
• More Levels
69
Learning From Others
70 / 60
StarCraft II Galaxy Editor
Learning From Others
71 / 60
StarCraft II Galaxy Editor
Learning From Others
72 / 60
StarCraft II Galaxy Editor
Learning From Others
73 / 60
World of Warcraft LUA UI API
Learning From Others
74 / 60
Hearthstone Log File
Learning From Others
75 / 60
StarCraft II Screenshot
Learning From Others
76 / 60
StarCraft II Screenshot
Learning From Others
77 / 60
StarCraft II Screenshot
Learning From Others
78 / 60
StarCraft II Screenshot
Learning From Others
79 / 60
StarCraft II Screenshot
Learning From Others
80 / 60
StarCraft II Screenshot
Learning From Others
81 / 60
StarCraft II Screenshot
Learning From Others
82 / 60
StarCraft II Screenshot
Learning From Others
83 / 60
Unreal Tournament 3 Splash Screen
Learning From Others
84 / 60
Unreal Tournament 3 Login Screen
Learning From Others
85 / 60
Hostile Worlds Screen Transitions
Learning From Others
86 / 60
Steam Server Browser
Learning From Others
87 / 60
WarCraft III Lobby
Learning From Others
88 / 60
WarCraft III Loading Screen
Learning From Others
89 / 60
WarCraft III Score Screen
Learning From Others
90 / 60
StarCraft II Options Screen
Learning From Others
91 / 60
Doom 3 GPL Release on GitHub
Learning From Others
92 / 60
Post-Mortem of WarCraft
Don’t Reinvent The Wheel
93 / 60
HOTween
There might even be cookies.
94 / 60
Source: UTWeap_LinkGun.uc (August UDK 2010)
/** Holds the list of link guns linked to this weapon */
var array<UTWeap_LinkGun> LinkedList; // I made a funny Hahahahah :)
Thank you for your attention!
Contact
Mail
dev@npruehs.de
Blog
http://www.npruehs.de
Twitter
@npruehs
Github
https://github.com/npruehs
95 / 60

Weitere ähnliche Inhalte

Was ist angesagt?

Game Programming 02 - Component-Based Entity Systems
Game Programming 02 - Component-Based Entity SystemsGame Programming 02 - Component-Based Entity Systems
Game Programming 02 - Component-Based Entity SystemsNick Pruehs
 
Entity Component Systems
Entity Component SystemsEntity Component Systems
Entity Component SystemsYos Riady
 
GameDev 2017 - Анатолій Ландишев "AAA architecture in Unity3D"
GameDev 2017 - Анатолій Ландишев "AAA architecture in Unity3D"GameDev 2017 - Анатолій Ландишев "AAA architecture in Unity3D"
GameDev 2017 - Анатолій Ландишев "AAA architecture in Unity3D"Lviv Startup Club
 
Unity introduction for programmers
Unity introduction for programmersUnity introduction for programmers
Unity introduction for programmersNoam Gat
 
OGDC 2014: Component based entity system mobile game development
OGDC 2014: Component based entity system mobile game developmentOGDC 2014: Component based entity system mobile game development
OGDC 2014: Component based entity system mobile game developmentGameLandVN
 
Unreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game FrameworkUnreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game FrameworkNick Pruehs
 
Choosing A Game Engine - More Than Frames Per Second
Choosing A Game Engine - More Than Frames Per SecondChoosing A Game Engine - More Than Frames Per Second
Choosing A Game Engine - More Than Frames Per SecondNoam Gat
 
Unity scene file collaboration
Unity scene file collaborationUnity scene file collaboration
Unity scene file collaborationNoam Gat
 
Game Project / Working with Unity
Game Project / Working with UnityGame Project / Working with Unity
Game Project / Working with UnityPetri Lankoski
 
Game Development with Unity
Game Development with UnityGame Development with Unity
Game Development with Unitydavidluzgouveia
 
Unity3D Programming
Unity3D ProgrammingUnity3D Programming
Unity3D ProgrammingMichael Ivanov
 
The Basics of Unity - The Game Engine
The Basics of Unity - The Game EngineThe Basics of Unity - The Game Engine
The Basics of Unity - The Game EngineOrisysIndia
 
Unity Programming
Unity Programming Unity Programming
Unity Programming Sperasoft
 
Practical Guide for Optimizing Unity on Mobiles
Practical Guide for Optimizing Unity on MobilesPractical Guide for Optimizing Unity on Mobiles
Practical Guide for Optimizing Unity on MobilesValentin Simonov
 
Casual and Social Games with Unity
Casual and Social Games with UnityCasual and Social Games with Unity
Casual and Social Games with UnityTadej Gregorcic
 
Unity Introduction
Unity IntroductionUnity Introduction
Unity IntroductionJuwal Bose
 

Was ist angesagt? (20)

Game Programming 02 - Component-Based Entity Systems
Game Programming 02 - Component-Based Entity SystemsGame Programming 02 - Component-Based Entity Systems
Game Programming 02 - Component-Based Entity Systems
 
Entity Component Systems
Entity Component SystemsEntity Component Systems
Entity Component Systems
 
GameDev 2017 - Анатолій Ландишев "AAA architecture in Unity3D"
GameDev 2017 - Анатолій Ландишев "AAA architecture in Unity3D"GameDev 2017 - Анатолій Ландишев "AAA architecture in Unity3D"
GameDev 2017 - Анатолій Ландишев "AAA architecture in Unity3D"
 
Unity introduction for programmers
Unity introduction for programmersUnity introduction for programmers
Unity introduction for programmers
 
OGDC 2014: Component based entity system mobile game development
OGDC 2014: Component based entity system mobile game developmentOGDC 2014: Component based entity system mobile game development
OGDC 2014: Component based entity system mobile game development
 
Unreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game FrameworkUnreal Engine Basics 01 - Game Framework
Unreal Engine Basics 01 - Game Framework
 
Choosing A Game Engine - More Than Frames Per Second
Choosing A Game Engine - More Than Frames Per SecondChoosing A Game Engine - More Than Frames Per Second
Choosing A Game Engine - More Than Frames Per Second
 
Unity scene file collaboration
Unity scene file collaborationUnity scene file collaboration
Unity scene file collaboration
 
Game Project / Working with Unity
Game Project / Working with UnityGame Project / Working with Unity
Game Project / Working with Unity
 
Game Development with Unity
Game Development with UnityGame Development with Unity
Game Development with Unity
 
Unity
UnityUnity
Unity
 
Unity3D Programming
Unity3D ProgrammingUnity3D Programming
Unity3D Programming
 
The Basics of Unity - The Game Engine
The Basics of Unity - The Game EngineThe Basics of Unity - The Game Engine
The Basics of Unity - The Game Engine
 
Unity Programming
Unity Programming Unity Programming
Unity Programming
 
Game development unity
Game development unityGame development unity
Game development unity
 
Practical Guide for Optimizing Unity on Mobiles
Practical Guide for Optimizing Unity on MobilesPractical Guide for Optimizing Unity on Mobiles
Practical Guide for Optimizing Unity on Mobiles
 
Casual and Social Games with Unity
Casual and Social Games with UnityCasual and Social Games with Unity
Casual and Social Games with Unity
 
Unity 3D, A game engine
Unity 3D, A game engineUnity 3D, A game engine
Unity 3D, A game engine
 
Unity Introduction
Unity IntroductionUnity Introduction
Unity Introduction
 
Unity: Introduction
Unity: IntroductionUnity: Introduction
Unity: Introduction
 

Andere mochten auch

Tool Development A - Git
Tool Development A - GitTool Development A - Git
Tool Development A - GitNick Pruehs
 
Game Programming 04 - Style & Design Principles
Game Programming 04 - Style & Design PrinciplesGame Programming 04 - Style & Design Principles
Game Programming 04 - Style & Design PrinciplesNick Pruehs
 
Game Programming 03 - Git Flow
Game Programming 03 - Git FlowGame Programming 03 - Git Flow
Game Programming 03 - Git FlowNick Pruehs
 
Game Programming 13 - Debugging & Performance Optimization
Game Programming 13 - Debugging & Performance OptimizationGame Programming 13 - Debugging & Performance Optimization
Game Programming 13 - Debugging & Performance OptimizationNick Pruehs
 
Game Programming 08 - Tool Development
Game Programming 08 - Tool DevelopmentGame Programming 08 - Tool Development
Game Programming 08 - Tool DevelopmentNick Pruehs
 
Game Programming 10 - Localization
Game Programming 10 - LocalizationGame Programming 10 - Localization
Game Programming 10 - LocalizationNick Pruehs
 
Game Programming 09 - AI
Game Programming 09 - AIGame Programming 09 - AI
Game Programming 09 - AINick Pruehs
 
Game Programming 12 - Shaders
Game Programming 12 - ShadersGame Programming 12 - Shaders
Game Programming 12 - ShadersNick Pruehs
 
Game Programming 11 - Game Physics
Game Programming 11 - Game PhysicsGame Programming 11 - Game Physics
Game Programming 11 - Game PhysicsNick Pruehs
 
Game Development Challenges
Game Development ChallengesGame Development Challenges
Game Development ChallengesNick Pruehs
 
Scrum - but... Agile Game Development in Small Teams
Scrum - but... Agile Game Development in Small TeamsScrum - but... Agile Game Development in Small Teams
Scrum - but... Agile Game Development in Small TeamsNick Pruehs
 
Game Programming 05 - Development Tools
Game Programming 05 - Development ToolsGame Programming 05 - Development Tools
Game Programming 05 - Development ToolsNick Pruehs
 
Game Programming 06 - Automated Testing
Game Programming 06 - Automated TestingGame Programming 06 - Automated Testing
Game Programming 06 - Automated TestingNick Pruehs
 
Entity System Architecture with Unity - Unite Europe 2015
Entity System Architecture with Unity - Unite Europe 2015Entity System Architecture with Unity - Unite Europe 2015
Entity System Architecture with Unity - Unite Europe 2015Simon Schmid
 
Designing an actor model game architecture with Pony
Designing an actor model game architecture with PonyDesigning an actor model game architecture with Pony
Designing an actor model game architecture with PonyNick Pruehs
 
ECS architecture with Unity by example - Unite Europe 2016
ECS architecture with Unity by example - Unite Europe 2016ECS architecture with Unity by example - Unite Europe 2016
ECS architecture with Unity by example - Unite Europe 2016Simon Schmid
 
Clean, fast and simple with Entitas and Unity - Unite Melbourne 2016
Clean, fast and simple with Entitas and Unity - Unite Melbourne 2016Clean, fast and simple with Entitas and Unity - Unite Melbourne 2016
Clean, fast and simple with Entitas and Unity - Unite Melbourne 2016Simon Schmid
 

Andere mochten auch (18)

Tool Development A - Git
Tool Development A - GitTool Development A - Git
Tool Development A - Git
 
Game Programming 04 - Style & Design Principles
Game Programming 04 - Style & Design PrinciplesGame Programming 04 - Style & Design Principles
Game Programming 04 - Style & Design Principles
 
Game Programming 03 - Git Flow
Game Programming 03 - Git FlowGame Programming 03 - Git Flow
Game Programming 03 - Git Flow
 
Game Programming 13 - Debugging & Performance Optimization
Game Programming 13 - Debugging & Performance OptimizationGame Programming 13 - Debugging & Performance Optimization
Game Programming 13 - Debugging & Performance Optimization
 
Game Programming 08 - Tool Development
Game Programming 08 - Tool DevelopmentGame Programming 08 - Tool Development
Game Programming 08 - Tool Development
 
Game Programming 10 - Localization
Game Programming 10 - LocalizationGame Programming 10 - Localization
Game Programming 10 - Localization
 
Game Programming 09 - AI
Game Programming 09 - AIGame Programming 09 - AI
Game Programming 09 - AI
 
Game Programming 12 - Shaders
Game Programming 12 - ShadersGame Programming 12 - Shaders
Game Programming 12 - Shaders
 
Game Programming 11 - Game Physics
Game Programming 11 - Game PhysicsGame Programming 11 - Game Physics
Game Programming 11 - Game Physics
 
Game Development Challenges
Game Development ChallengesGame Development Challenges
Game Development Challenges
 
Scrum - but... Agile Game Development in Small Teams
Scrum - but... Agile Game Development in Small TeamsScrum - but... Agile Game Development in Small Teams
Scrum - but... Agile Game Development in Small Teams
 
Game Programming 05 - Development Tools
Game Programming 05 - Development ToolsGame Programming 05 - Development Tools
Game Programming 05 - Development Tools
 
Game Programming 06 - Automated Testing
Game Programming 06 - Automated TestingGame Programming 06 - Automated Testing
Game Programming 06 - Automated Testing
 
Entity System Architecture with Unity - Unite Europe 2015
Entity System Architecture with Unity - Unite Europe 2015Entity System Architecture with Unity - Unite Europe 2015
Entity System Architecture with Unity - Unite Europe 2015
 
Designing an actor model game architecture with Pony
Designing an actor model game architecture with PonyDesigning an actor model game architecture with Pony
Designing an actor model game architecture with Pony
 
ECS architecture with Unity by example - Unite Europe 2016
ECS architecture with Unity by example - Unite Europe 2016ECS architecture with Unity by example - Unite Europe 2016
ECS architecture with Unity by example - Unite Europe 2016
 
Clean, fast and simple with Entitas and Unity - Unite Melbourne 2016
Clean, fast and simple with Entitas and Unity - Unite Melbourne 2016Clean, fast and simple with Entitas and Unity - Unite Melbourne 2016
Clean, fast and simple with Entitas and Unity - Unite Melbourne 2016
 
AAA Automated Testing
AAA Automated TestingAAA Automated Testing
AAA Automated Testing
 

Ähnlich wie School For Games 2015 - Unity Engine Basics

Unity3 d devfest-2014
Unity3 d devfest-2014Unity3 d devfest-2014
Unity3 d devfest-2014Vincenzo Favara
 
Game Programming I - Introduction
Game Programming I - IntroductionGame Programming I - Introduction
Game Programming I - IntroductionFrancis SeriĂąa
 
WP7 HUB_XNA
WP7 HUB_XNAWP7 HUB_XNA
WP7 HUB_XNAMICTT Palma
 
WP7 HUB_XNA overview
WP7 HUB_XNA overviewWP7 HUB_XNA overview
WP7 HUB_XNA overviewMICTT Palma
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 MinigamesSusan Gold
 
Cross platform game development
Cross platform game developmentCross platform game development
Cross platform game developmentJerel Hass
 
Monogame and xna
Monogame and xnaMonogame and xna
Monogame and xnaLee Stott
 
How tomakea gameinunity3d
How tomakea gameinunity3dHow tomakea gameinunity3d
How tomakea gameinunity3dDao Tung
 
HoloLens Programming Tutorial: AirTap & Spatial Mapping
HoloLens Programming Tutorial: AirTap & Spatial MappingHoloLens Programming Tutorial: AirTap & Spatial Mapping
HoloLens Programming Tutorial: AirTap & Spatial MappingTakashi Yoshinaga
 
38199728 multi-player-tutorial
38199728 multi-player-tutorial38199728 multi-player-tutorial
38199728 multi-player-tutorialalfrecaay
 
Getting started with Verold and Three.js
Getting started with Verold and Three.jsGetting started with Verold and Three.js
Getting started with Verold and Three.jsVerold
 
Academy PRO: Unity 3D. Environment
Academy PRO: Unity 3D. EnvironmentAcademy PRO: Unity 3D. Environment
Academy PRO: Unity 3D. EnvironmentBinary Studio
 
Unity3d scripting tutorial
Unity3d scripting tutorialUnity3d scripting tutorial
Unity3d scripting tutorialhungnttg
 
Lightweight Multiplayer HTML5 Games with PubNub
Lightweight Multiplayer HTML5 Games with PubNubLightweight Multiplayer HTML5 Games with PubNub
Lightweight Multiplayer HTML5 Games with PubNubPubNub
 
Cmd unity withc
Cmd unity withcCmd unity withc
Cmd unity withcumairnoora
 
A split screen-viable UI event system - Unite Copenhagen 2019
A split screen-viable UI event system - Unite Copenhagen 2019A split screen-viable UI event system - Unite Copenhagen 2019
A split screen-viable UI event system - Unite Copenhagen 2019Unity Technologies
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxyginecorehard_by
 
Game Development Session - 3 | Introduction to Unity
Game Development Session - 3 | Introduction to  UnityGame Development Session - 3 | Introduction to  Unity
Game Development Session - 3 | Introduction to UnityKoderunners
 

Ähnlich wie School For Games 2015 - Unity Engine Basics (20)

Unity3 d devfest-2014
Unity3 d devfest-2014Unity3 d devfest-2014
Unity3 d devfest-2014
 
Game Programming I - Introduction
Game Programming I - IntroductionGame Programming I - Introduction
Game Programming I - Introduction
 
Unity workshop
Unity workshopUnity workshop
Unity workshop
 
WP7 HUB_XNA
WP7 HUB_XNAWP7 HUB_XNA
WP7 HUB_XNA
 
WP7 HUB_XNA overview
WP7 HUB_XNA overviewWP7 HUB_XNA overview
WP7 HUB_XNA overview
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 Minigames
 
Cross platform game development
Cross platform game developmentCross platform game development
Cross platform game development
 
Monogame and xna
Monogame and xnaMonogame and xna
Monogame and xna
 
PresentaciĂłn Unity
PresentaciĂłn UnityPresentaciĂłn Unity
PresentaciĂłn Unity
 
How tomakea gameinunity3d
How tomakea gameinunity3dHow tomakea gameinunity3d
How tomakea gameinunity3d
 
HoloLens Programming Tutorial: AirTap & Spatial Mapping
HoloLens Programming Tutorial: AirTap & Spatial MappingHoloLens Programming Tutorial: AirTap & Spatial Mapping
HoloLens Programming Tutorial: AirTap & Spatial Mapping
 
38199728 multi-player-tutorial
38199728 multi-player-tutorial38199728 multi-player-tutorial
38199728 multi-player-tutorial
 
Getting started with Verold and Three.js
Getting started with Verold and Three.jsGetting started with Verold and Three.js
Getting started with Verold and Three.js
 
Academy PRO: Unity 3D. Environment
Academy PRO: Unity 3D. EnvironmentAcademy PRO: Unity 3D. Environment
Academy PRO: Unity 3D. Environment
 
Unity3d scripting tutorial
Unity3d scripting tutorialUnity3d scripting tutorial
Unity3d scripting tutorial
 
Lightweight Multiplayer HTML5 Games with PubNub
Lightweight Multiplayer HTML5 Games with PubNubLightweight Multiplayer HTML5 Games with PubNub
Lightweight Multiplayer HTML5 Games with PubNub
 
Cmd unity withc
Cmd unity withcCmd unity withc
Cmd unity withc
 
A split screen-viable UI event system - Unite Copenhagen 2019
A split screen-viable UI event system - Unite Copenhagen 2019A split screen-viable UI event system - Unite Copenhagen 2019
A split screen-viable UI event system - Unite Copenhagen 2019
 
C++ game development with oxygine
C++ game development with oxygineC++ game development with oxygine
C++ game development with oxygine
 
Game Development Session - 3 | Introduction to Unity
Game Development Session - 3 | Introduction to  UnityGame Development Session - 3 | Introduction to  Unity
Game Development Session - 3 | Introduction to Unity
 

Mehr von Nick Pruehs

Unreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual EffectsUnreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual EffectsNick Pruehs
 
Unreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceUnreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceNick Pruehs
 
Unreal Engine Basics 04 - Behavior Trees
Unreal Engine Basics 04 - Behavior TreesUnreal Engine Basics 04 - Behavior Trees
Unreal Engine Basics 04 - Behavior TreesNick Pruehs
 
Unreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - GameplayUnreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - GameplayNick Pruehs
 
Unreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorUnreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorNick Pruehs
 
Game Programming - Cloud Development
Game Programming - Cloud DevelopmentGame Programming - Cloud Development
Game Programming - Cloud DevelopmentNick Pruehs
 
Game Programming - Git
Game Programming - GitGame Programming - Git
Game Programming - GitNick Pruehs
 
Game Programming 00 - Exams
Game Programming 00 - ExamsGame Programming 00 - Exams
Game Programming 00 - ExamsNick Pruehs
 
Tool Development 10 - MVVM, Tool Chains
Tool Development 10 - MVVM, Tool ChainsTool Development 10 - MVVM, Tool Chains
Tool Development 10 - MVVM, Tool ChainsNick Pruehs
 

Mehr von Nick Pruehs (9)

Unreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual EffectsUnreal Engine Basics 06 - Animation, Audio, Visual Effects
Unreal Engine Basics 06 - Animation, Audio, Visual Effects
 
Unreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceUnreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User Interface
 
Unreal Engine Basics 04 - Behavior Trees
Unreal Engine Basics 04 - Behavior TreesUnreal Engine Basics 04 - Behavior Trees
Unreal Engine Basics 04 - Behavior Trees
 
Unreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - GameplayUnreal Engine Basics 03 - Gameplay
Unreal Engine Basics 03 - Gameplay
 
Unreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorUnreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal Editor
 
Game Programming - Cloud Development
Game Programming - Cloud DevelopmentGame Programming - Cloud Development
Game Programming - Cloud Development
 
Game Programming - Git
Game Programming - GitGame Programming - Git
Game Programming - Git
 
Game Programming 00 - Exams
Game Programming 00 - ExamsGame Programming 00 - Exams
Game Programming 00 - Exams
 
Tool Development 10 - MVVM, Tool Chains
Tool Development 10 - MVVM, Tool ChainsTool Development 10 - MVVM, Tool Chains
Tool Development 10 - MVVM, Tool Chains
 

KĂźrzlich hochgeladen

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vĂĄzquez
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

KĂźrzlich hochgeladen (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

School For Games 2015 - Unity Engine Basics

  • 1. Game Development Grundlagen der Unity-Engine Nick PrĂźhs
  • 2. About Me “Best Bachelor“ Computer Science Kiel University, 2009 Master Games Hamburg University of Applied Sciences, 2011 Lead Programmer Daedalic Entertainment, 2011-2012 Co-Founder slash games, 2013 Microsoft MVP 2015 2 / 12
  • 3. First Things First • At npruehs.de/teaching you‘ll find all slides • Ask your questions – any time! • Contact me any time at dev@npruehs.de! 3 / 12
  • 4. Objectives • To understand the fundamentals of game lifecycles • To learn how to build a small game with Unity3D • To get an idea of how to learn from others 4 / 60
  • 6. New Unity Project Unity projects contain multiple different files and folders • Assets (3D Models, Images, Code) • Settings (Input, Phyiscs) • Temporary Files (imported assets, see later) 6 / 12
  • 7. Unity Editor Layout – 2 by 3 7 / 12
  • 8. Unity Editor Layout – 2 by 3 The scene view shows all objects of the level and allows free movement. 8 / 12
  • 9. Unity Editor Layout – 2 by 3 The game view shows the level as seen by the camera. 9 / 12
  • 10. Unity Editor Layout – 2 by 3 The hierarchy provides an overview of all scene objects. 10 / 12
  • 11. Unity Editor Layout – 2 by 3 The project view contains all assets (3D models, code) of your project. 11 / 12
  • 12. Unity Editor Layout – 2 by 3 The inspector shows the details of the selected game object. 12 / 12
  • 13. Unity Camera 13 / 12 The camera draws scene objects as seen from its position.
  • 14. Asset Import Unity imports all of your assets so it understands how to use them properly. (Thanks, Unity!) 14 / 12
  • 15. Asset Import Unity imports all of your assets so it understands how to use them properly. (Thanks, Unity!) 15 / 12
  • 16. Game Loop Update Draw 16 Init Shutdown The game lifecycle is split up into four major steps.
  • 17. Game Loop Update Draw 17 Init Shutdown During initialization, the game sets up everything to run properly, such as preparing the graphics device, loading all assets, or opening a log file.
  • 18. Game Loop Update Draw 18 Init Shutdown In each update, all game objects may change their properties, such as position, health, or cooldown timer.
  • 19. Game Loop Update Draw 19 Init Shutdown Then, the game tells the graphics device what to draw, where, and how.
  • 20. Game Loop Update Draw 20 Init Shutdown Finally, the game needs to shut down properly, returning the graphics device to the operating system, for example.
  • 21. Our First Script! Now that we’ve got our little space ship ready, it’s time to add some action! We want to do two things now: 1. Check if the player pressed a button. 2. Move the space ship if he or she did. 21 / 12
  • 22. Our First Script! 22 / 12 In Unity, we can attach scripts to game objects. Each script will describe the behavior of that particular game object.
  • 23. Our First Script! C# 23 // Use the magic code Unity provides for us. using UnityEngine; using System.Collections; // Name of the script. public class KeyboardMovement : MonoBehaviour { // Use this for initialization. void Start () { // Nothing to do here, yay! } // Update is called once per frame. void Update () { // Check if player pressed any button. if (Input.GetKey(KeyCode.W)) { // Add "forward" vector to current position. this.transform.localPosition += Vector3.forward; } } }
  • 24. Our First Script! // Use the magic code Unity provides for us. using UnityEngine; using System.Collections; Whew, that’s a lot of stuff. Let’s take a detailed look at that! First, game engines like Unity and frameworks like .NET save us from writing the same code over and over again (e.g. vector math, lists). 24 / 12
  • 25. Our First Script! // Name of the script. public class KeyboardMovement:MonoBehaviour { … } Clearly, Unity needs to know the name of our script. The other stuff (public, class, MonoBehaviour, that strange colon, …) won’t be covered here. Go to a dedicated computer science class for that ;) 25 / 12
  • 26. Our First Script! // Use this for initialization. void Start () { // Nothing to do here, yay! } 26 / 12 Remember the initialization we sometimes need to do before entering the game loop? Unity allows us to that right here, right now!
  • 27. Our First Script! // Use this for initialization. void Start () { // Nothing to do here, yay! } Remember the initialization we sometimes need to do before entering the game loop? Unity allows us to that right here, right now! (Thanks, Unity!) 27 / 12
  • 28. Our First Script! // Check if player pressed any button. if (Input.GetKey(KeyCode.W)) { … } Unity even intercepts keyboard input for us. All we need to do is ask ;) 28 / 12
  • 29. Our First Script! // Add "forward" vector to current position. this.transform.localPosition += Vector3.forward; Unity stores information relevant for drawing the scene with our camera in a transform. This includes the position of an object, its rotation, and its scale. 29 / 12
  • 30. Vector Math Think of vectors as sets of coordinates in our coordinate system: 𝑣 = 𝑥 𝑦 𝑧 30 / 12
  • 31. Vector Math Just as numbers, you can add vectors, resulting in a new set of numbers: 𝑣1 + 𝑣2 = 𝑥1 𝑦1 𝑧1 + 𝑥2 𝑦2 𝑧2 = 𝑥1 + 𝑥2 𝑦1 + 𝑦2 𝑧1 + 𝑧2 31 / 12
  • 32. Vector Math Just as numbers, you can add vectors, resulting in a new set of numbers: 𝑣1 + 𝑣2 = 1 2 3 + 4 5 6 = 5 7 9 32 / 12
  • 33. Our First Script! // Add "forward" vector to current position. this.transform.localPosition += Vector3.forward; We can access the transform of the game object the script is attached to using the this keyword. Then, we can modify its position by using the += operator. 33 / 12
  • 34. Our First Script! Whew, that was fast! Maybe we should improve our code here a bit. 1. Our spaceship should have its own speed value. This will also allow us to have different ships with different speed! 2. We should take the frame time of our game into account. Otherwise, our spaceship would be faster if our PC is faster – unfair! 34 / 12
  • 35. Our First Script! C# 35 // Use the magic code Unity provides for us. using UnityEngine; using System.Collections; // Name of the script. public class KeyboardMovement : MonoBehaviour { // Speed of this game object. public float Speed; // Use this for initialization. void Start () { // Nothing to do here, yay! } // Update is called once per frame. void Update () { // Check if player pressed any button. if (Input.GetKey(KeyCode.W)) { // Add "forward" vector to current position. this.transform.localPosition += Vector3.forward * this.Speed * Time.deltaTime; } } }
  • 36. Our First Script! // Speed of this game object. public float Speed; Here, speed is a variable (like x in your math class). public means, everybody can change the speed value. float means, speed may be a fraction (like 1.4) 36 / 12
  • 37. Our First Script! 37 / 12 Unity exposes public variables in the inspector we were talking about earlier. Change the speed value and see what happens!
  • 38. A Nice Space Background Lets pick up a nice space image from the official NASA website: http://apod.nasa.gov/ap od/ap120828.html 38
  • 39. A Nice Space Background Now, let’s change the texture import settings of our background: Set Wrap Mode to Clamp. 39
  • 40. A Nice Space Background Next, we need to create a material for the skybox to use with our camera. • Set the shader to Skybox/6 Sided. • Assign the texture to all six slots. 40
  • 41. A Nice Space Background Finally, we can change the scene lighting settings to use our brand-new skybox! 41
  • 42. Let’s make a side-scroller! Just change the position and rotation of your camera – easy! 42 / 12
  • 43. Let’s make a side-scroller! You can also reduce the field of view to ensure the skybox looks nice. 43 / 12
  • 44. Adjusted Movement C# 44 // Update is called once per frame. void Update () { // Check if player pressed any button. if (Input.GetKey(KeyCode.W)) { // Add “up" vector to current position. this.transform.localPosition += Vector3.up * this.Speed * Time.deltaTime; } if (Input.GetKey(KeyCode.S)) { // Add “down" vector to current position. this.transform.localPosition += Vector3.down * this.Speed * Time.deltaTime; } if (Input.GetKey(KeyCode.A)) { // Add “back" vector to current position. this.transform.localPosition += Vector3.back * this.Speed * Time.deltaTime; } if (Input.GetKey(KeyCode.D)) { // Add "forward" vector to current position. this.transform.localPosition += Vector3.forward * this.Speed * Time.deltaTime; } }
  • 45. Now for some real action! We want our spaceship to fire its weapons! For this, we need to: 1. Add a projectile to our project. 2. Create a projectile whenever the player presses a button. 45 / 12
  • 46. Unity Prefabs 46 / 12 Unity allows us to create prefabs of our game objects. Think of prefabs as “Schablonen” for new game objects.
  • 47. Our Second Script! C# 47 // Use the magic code Unity provides for us. using UnityEngine; using System.Collections; // Name of the script. public class KeyboardFire : MonoBehaviour { // Prefab to use as projectile. public GameObject ProjectilePrefab; // Use this for initialization void Start () { // Still nothing to do, yay! } // Update is called once per frame void Update () { // Check if player pressed the SPACE button. if (Input.GetKey(KeyCode.Space)) { // Fire projectile! Instantiate(this.ProjectilePrefab, this.transform.position, this.transform.rotation); } } }
  • 48. Boring projectiles are boring C# 48 // Use the magic code Unity provides for us. using UnityEngine; using System.Collections; // Name of the script. public class AutomaticMovement : MonoBehaviour { // Speed of this game object. public float Speed; // Update is called once per frame void Update () { // Fly "forward" automatically. this.transform.localPosition += Vector3.forward * this.Speed * Time.deltaTime; } }
  • 49. Hint Splitting up your code across multiple components is always a better idea than writing huge, monolithic code files! 49 / 61
  • 50. Game Objects • objects in your game world can (or cannot)… • be visible • move around • attack • explode • be targeted • become selected • follow a path • common across all genres 50 / 57
  • 52. There are probably hundreds of ways… Then one day your designer says that they want a new type of “alien” asteroid that acts just like a heat seeking missile, except it’s still an asteroid.” - Scott Bilas 52 / 57
  • 54. Camera Movement 54 / 12 Right now, we can easily leave the screen, if we want to. Let’s change that: 1. Reparent the camera to our player ship. 2. Add the automatic movement script to the player ship.
  • 55. Unity Hierarchy 55 / 12 If a game object in Unity is a child of another, its transform is relative to the one of its parent: • Position • Rotation • Scale
  • 56. Adding Enemies Time to add our first enemies! We need to … 1. Create a prefab for our enemy space ship. 2. Rotate enemies correctly. 3. Modify their movement. 56 / 12
  • 57. Automated Movement With Direction C# 57 // Use the magic code Unity provides for us. using UnityEngine; using System.Collections; // Name of the script. public class AutomaticMovement : MonoBehaviour { // Velocity of this game object. public Vector3 Velocity; // Update is called once per frame void Update () { // Fly "forward" automatically. this.transform.localPosition += this.Velocity * Time.deltaTime; } }
  • 59. Taking Damage Next, we want to keep track of the health value of each ship. After all, we want to destroy our enemies, don’t we? We need to: 1. Write a script keeping track of spaceship health. 2. Check for collisions of projectiles with ships. 3. Reduce health when projectiles hit ships. 59 / 12
  • 60. Spaceship Health C# 60 // Use the magic code Unity provides for us. using UnityEngine; using System.Collections; // Name of the script. public class Health : MonoBehaviour { // Health of this game object. public float CurrentHealth; // Update is called once per frame void Update () { // Destroy when dead. if (this.CurrentHealth <= 0) { Destroy (this.gameObject); } } }
  • 61. Hint The if operator in C# allows us to add conditions to our code. It’s always a good idea not to compare numbers for exact values (<= instead of ==) 61 / 12
  • 62. Handling Collisions As you can imagine, finding out whether two objects collide can include some terrible math. In Unity, colliders can be used to approximate the extents of a game object for easier collision detection. 62 / 12
  • 63. Handling Collisions Let’s add a sphere collider for our space ship and projectiles! 63 / 12
  • 64. Handling Collisions If your collider moves (just like our ships and projectiles), we need to add a rigidbody as well. Make sure to disable “Use Gravity”, or Unity will make our spaceships fall down. 64 / 12
  • 65. Handling Collisions Whenever two objects collide, Unity won’t allow them to intersect each other. Check “Is Trigger” to allow these objects to intersect! 65 / 12
  • 66. Handling Collisions C# 66 // Use the magic code Unity provides for us. using UnityEngine; using System.Collections; // Name of the script. public class DamageOnCollision : MonoBehaviour { // Damage this game object deals on collision. public float Damage; // OnCollisionEnter is called whenever we collide with somebody else. void OnTriggerEnter(Collider other) { // Get the health component of the other object. Health health = other.gameObject.GetComponent<Health> (); if (health != null) { // Reduce health. health.CurrentHealth -= this.Damage; // Destroy this game object. Destroy (this.gameObject); } } }
  • 67. Finishing Touches 67 / 12 Now, your job as programmer is done – time for the designer in you! Add enemies to the level any play, play, play!
  • 68. Building The Game 68 / 12 Finally, we can build our game, to show everyone and share the fun 
  • 69. Where To Go From Here As with every software project, there’s always more to do… • Enemy Fire • Enemy AI • Menus • Explosions • Score • Cheats • More Enemies • More Levels 69
  • 70. Learning From Others 70 / 60 StarCraft II Galaxy Editor
  • 71. Learning From Others 71 / 60 StarCraft II Galaxy Editor
  • 72. Learning From Others 72 / 60 StarCraft II Galaxy Editor
  • 73. Learning From Others 73 / 60 World of Warcraft LUA UI API
  • 74. Learning From Others 74 / 60 Hearthstone Log File
  • 75. Learning From Others 75 / 60 StarCraft II Screenshot
  • 76. Learning From Others 76 / 60 StarCraft II Screenshot
  • 77. Learning From Others 77 / 60 StarCraft II Screenshot
  • 78. Learning From Others 78 / 60 StarCraft II Screenshot
  • 79. Learning From Others 79 / 60 StarCraft II Screenshot
  • 80. Learning From Others 80 / 60 StarCraft II Screenshot
  • 81. Learning From Others 81 / 60 StarCraft II Screenshot
  • 82. Learning From Others 82 / 60 StarCraft II Screenshot
  • 83. Learning From Others 83 / 60 Unreal Tournament 3 Splash Screen
  • 84. Learning From Others 84 / 60 Unreal Tournament 3 Login Screen
  • 85. Learning From Others 85 / 60 Hostile Worlds Screen Transitions
  • 86. Learning From Others 86 / 60 Steam Server Browser
  • 87. Learning From Others 87 / 60 WarCraft III Lobby
  • 88. Learning From Others 88 / 60 WarCraft III Loading Screen
  • 89. Learning From Others 89 / 60 WarCraft III Score Screen
  • 90. Learning From Others 90 / 60 StarCraft II Options Screen
  • 91. Learning From Others 91 / 60 Doom 3 GPL Release on GitHub
  • 92. Learning From Others 92 / 60 Post-Mortem of WarCraft
  • 93. Don’t Reinvent The Wheel 93 / 60 HOTween
  • 94. There might even be cookies. 94 / 60 Source: UTWeap_LinkGun.uc (August UDK 2010) /** Holds the list of link guns linked to this weapon */ var array<UTWeap_LinkGun> LinkedList; // I made a funny Hahahahah :)
  • 95. Thank you for your attention! Contact Mail dev@npruehs.de Blog http://www.npruehs.de Twitter @npruehs Github https://github.com/npruehs 95 / 60