Intro to Unity Engine�& modern game engine architecture
CPSC 4820/6820 Game Design
Yang Hu
CU GAME Lab
About Me
Game
Designer & Developer
Game Engine & Graphics
Developer
Human-Centered Computing Research
About Me
Game
Designer & Developer
Game Engine & Graphics
Developer
Human-Centered Computing Research
NO!!! Not Yet :P
What is a game engine?
What can game engines do?
A brief Unity walk through
How to code in Unity?
Other game engines (makers)
What is a game engine?
What is a game engine?
Early game engines
reusable code bases
from previous games
Modern commercial
game engines
A tool set
for all game developers
Doom (1993)
Quake(1995)
Unity
Unreal
What can game engines do?
Audio
Models, animations, lights, shadows...
Rendering
Physics
Collisions, movements, gravities...
Input system, animation system, file manager, AI, networking...
What can game engines do?
Audio
Models, animations, lights, shadows...
Rendering
Physics
Collisions, movements, gravities...
What can game engines do?
What can game engines do?
Frame Rate
or
Frame Per Second (FPS)
What can game engines do?
What can game engines do?
60 Images
per second
0.01667 seconds
for 1 image
What can game engines do?
What can game engines do?
What can game engines do?
What can game engines do?
What can game engines do?
What can game engines do?
What can game engines do?
main() {
game_begins();
game_ends();
return 0;
{
What can game engines do?
main() {
game_begins();
while( game_is_running() ) {
begin_frame();
end_frame();
}
game_ends();
return 0;
{
What can game engines do?
main() {
game_begins();
while( game_is_running() ) {
begin_frame();
for( each _object in _scene ) {
_calculate_physics();
_trigger_sound();
_render();
}
end_frame();
}
game_ends();
return 0;
{
What can game engines do?
main() {
game_begins();
while( game_is_running() ) {
begin_frame();
for( each _object in _scene ) {
_calculate_physics();
_trigger_sound();
_render();
}
end_frame();
}
game_ends();
return 0;
{
What if they cannot be done within the frame rate limit?
(in 16.67 milliseconds)
What can game engines do?
while( game_is_running() ) {
begin_frame();
for( each _object in _scene ) {
_calculate_physics();
_trigger_sound();
_render();
}
end_frame();
}
What can game engines do?
What can game engines do?
while( game_is_running() ) {
begin_frame();
for( each _object in _scene ) {
_calculate_physics();
_trigger_sound();
_render();
}
end_frame();
}
What can game engines do?
while( game_is_running() ) {
begin_frame();
for( each _object in _scene ) {
_calculate_physics();
_trigger_sound();
_render();
}
end_frame();
}
What can game engines do?
Object Model
Object Model
Terrain Model
Particle Effect
Object Collider
Object Collider
Terrain Collider
GameObject
Components
Can Move
Can Move
Cannot Move
Empty Object
Object Collider
A brief Unity walk through
A brief Unity walk through
A brief Unity walk through
Create
and
manage
objects
Create
and
manage
objects
3D Model
3D Model
Terrain Model
Particle Effect
Object Collider
Object Collider
Terrain Collider
GameObject
Components
Cannot Move
Move Simulation
Can Move
Cannot Move
3D Model
Object Collider
Can Move
How to code in Unity?
Include namespaces
allow you to use the functions under these namespaces
Class inheritance
Called once when game start
Called for every frame
How to code in Unity
Start()
Start()
Start()
Start()
Update()
Update()
Update()
Update()
Update()
Update()
Update()
Update()
Update()
Update()
Update()
Update()
Render
Render
Render
Render
Let’s make a mini game
A workflow in an Unity Project
A workflow in an Unity Project
1. Play with Unity (right now)
a. Watch tutorials for different game genres
i. 2D platformer, 2D topdown, 3D action, etc
b. Ask yourself: can I do this?
c. Ask your team: can we do this?
i. Find a common ground for your team. Do not try to do everything by yourself.
A workflow in an Unity Project
2. Do mini game jams (preferably offline meeting, do as many times as you can)
THIS IS FUN!!!
a. Find a past game jam theme
i. e.g., GMTK Game Jam on YouTube
b. Do 30 minutes self-brainstorm and 30 minutes discussion to exchange ideas
c. Watch the best games selected
video for that game jam together
d. Ask yourself and your team
i. Can we code
game mechanics like this?
ii. Can we make
art resources like this?
A workflow in an Unity Project
3. Pick your game idea
a. game genre, target experience, art style, narrative, special mechanics, etc.
4. Set up a plan and workflow
a. Number of scenes, levels,
length of the game
b. Amount of codes
c. Number of art resources,
what are they
i.like we need 31 64 x 64
pixel art and 13 UI
elements
A workflow in an Unity Project
5. Regular check-in
a. I recommend everyone to write down what they have done for each week
i. for example, what video tutorial they watched, what Unity experiment they tried, what art resources they have made, etc.
6. Final Note: Make a rough, playable version first, then add details / levels / art resources, etc.
a. This helps you to
more clearly envision
your project and iterate
your ideas
Thanks
1. Play with Unity (right now)
a. Watch tutorials for different game genres
i. 2D platformer, 2D topdown, 3D action, etc
b. Ask yourself: can I do this?
c. Ask your team: can we do this?
i. Find a common ground for your team. Do not try to do everything by yourself.
2. Do mini game jams (preferably offline meeting, do as many times as you can)
THIS IS FUN!!!
a. Find a past game jam theme
i. e.g., GMTK Game Jam on YouTube
b. Do 30 minutes self-brainstorm and 30 minutes discussion to exchange ideas
c. Watch the “best games” video for that game jam with your team
d. Ask yourself and your team
i. Can we code game mechanics like this?
ii. Can we make art resources like this?
3. Pick your game idea
a. game genre, target experience, art style, narrative, special mechanic, etc.
4. Assign roles
5. Set up a plan and workflow
a. Number of scenes, levels, characters, length of the game
b. Number of codes (you should gain a clear idea about this if you have watched some complete Unity tutorials
b. Number of art resources, what are they (like we need 31 64 x 64 pixel art and 13 UI elements)
6. Regular check-in
a. I recommend everyone to write down what they have done for each week
i. for example, what video tutorial they watched, what Unity experiment they tried, what art resources they have made, etc.
7. Final Note: Make a rough, playable version first, then add details / levels / art resources, etc.
a. This helps you to more clearly envision your project and iterate your ideas
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveCube : MonoBehaviour
{
public float speed;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float h = Input.GetAxis("Horizontal"); // returns -1 or 1
float v = Input.GetAxis("Vertical"); // returns -1 or 1
Vector3 MovDir = new Vector3(h, 0, v); // something
// like (1,0,0)
MovDir = MovDir * speed * Time.deltaTime; // delta time refers to the time spent during the last frame. This helps you to calibrate strange movements caused by unstable frame rates by binding objects movements to real time.
gameObject.transform.position += MovDir; // update position
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LevelClear : MonoBehaviour
{
public int winScale = 10;
void OnCollisionEnter(Collision collision)
{
gameObject.transform.localScale =
new Vector3(winScale, winScale, winScale);
}
}
Note: Some object names here turns into blue. This kind of object is called “prefab”. Whenever you drag an object from hierarchy to the project file window ->, it becomes a prefab, which means a stored blueprint of that object. This is especially useful when you want to respawn an object multiple times or into different variants. You can simply store that blueprint in your spawner object and instantiate it when needed.
Other game engines (makers)
Other game engines (makers)
RPG Maker
(Steam)
Other game engines (makers)