Game Programming Paradigms. Michael Chung

Similar documents
Game Architecture. Rabin is a good overview of everything to do with Games A lot of these slides come from the 1 st edition CS

the gamedesigninitiative at cornell university Lecture 10 Game Architecture

CS 354R: Computer Game Technology

INTRODUCTION TO GAME AI

Introduction to Game Design. Truong Tuan Anh CSE-HCMUT

Sensible Chuckle SuperTuxKart Concrete Architecture Report

Transitioning From Linear to Open World Design with Sunset Overdrive. Liz England Designer at Insomniac Games

Unity Certified Programmer

Adding in 3D Models and Animations

the gamedesigninitiative at cornell university Lecture 20 Optimizing Behavior

Procedural Level Generation for a 2D Platformer

Killzone Shadow Fall: Threading the Entity Update on PS4. Jorrit Rouwé Lead Game Tech, Guerrilla Games

Towards a Reference Architecture for 3D First Person Shooter Games

Pangolin: A Look at the Conceptual Architecture of SuperTuxKart. Caleb Aikens Russell Dawes Mohammed Gasmallah Leonard Ha Vincent Hung Joseph Landy

Game Design Comp 150GD. Michael Shah 3/6/15

In the end, the code and tips in this document could be used to create any type of camera.

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

G54GAM - Games. So.ware architecture of a game

Space Invadersesque 2D shooter

8 Frames in 16ms. Michael Stallone Lead Software Engineer Engine NetherRealm Studios

CAPSTONE PROJECT 1.A: OVERVIEW. Purpose

Surfing on a Sine Wave

Local Perception Filter

Israel Railways No Fault Liability Renewal The Implementation of New Technological Safety Devices at Level Crossings. Amos Gellert, Nataly Kats

CISC 1600, Lab 2.2: More games in Scratch

Blunt object, meet nail. Choosing tools and wrangling Unity

Unity 3.x. Game Development Essentials. Game development with C# and Javascript PUBLISHING

SIMGRAPH - A FLIGHT SIMULATION DATA VISUALIZATION WORKSTATION. Joseph A. Kaplan NASA Langley Research Center Hampton, Virginia

CS 354R: Computer Game Technology

Workshop 4: Digital Media By Daniel Crippa

Pangolin: Concrete Architecture of SuperTuxKart. Caleb Aikens Russell Dawes Mohammed Gasmallah Leonard Ha Vincent Hung Joseph Landy

THAT Corporation APPLICATION NOTE 102

AUTOMATED TESTING & INSTANT REPLAYS

Create a benchmark mobile game! Tobias Tost Senior Programmer, Blue Byte GmbH A Ubisoft Studio

Chapter 1:Object Interaction with Blueprints. Creating a project and the first level

Outline. Introduction to Game Programming Autumn Game architecture. The (classic) game loop. Fundamental concepts

A RESEARCH PAPER ON ENDLESS FUN

Instructions for using Object Collection and Trigger mechanics in Unity

Session 11 Introduction to Robotics and Programming mbot. >_ {Code4Loop}; Roochir Purani

University of Manchester School of Computer Science Project Report Universalum the Universal Game. Author: A. Prohhorov

CRYPTOSHOOTER MULTI AGENT BASED SECRET COMMUNICATION IN AUGMENTED VIRTUALITY

Kameleono. User Guide Ver 1.2.3

Editing the standing Lazarus object to detect for being freed

Unity Game Development Essentials

G54GAM Lab Session 1

Final Design Report. Project Title: Multi-Function Pontoon (MFP)

GAME PROGRAMMING & DESIGN LAB 1 Egg Catcher - a simple SCRATCH game

The purpose of this document is to outline the structure and tools that come with FPS Control.

M TE S Y S LT U A S S A

In this project you ll learn how to create a times table quiz, in which you have to get as many answers correct as you can in 30 seconds.

Overview. The Game Idea

Tic Feedback. Don t fall behind! the rest of the course. tic. you. us too

Team Development of Model View Controller Software in the Unity 3D Engine

Design of Embedded Systems - Advanced Course Project

CMSC 425: Lecture 3 Introduction to Unity

BE SURE TO COMPLETE HYPOTHESIS STATEMENTS FOR EACH STAGE. ( ) DO NOT USE THE TEST BUTTON IN THIS ACTIVITY UNTIL THE END!

Foreword Thank you for purchasing the Motion Controller!

Game Design 1. Unit 1: Games and Gameplay. Learning Objectives. After studying this unit, you will be able to:

abc 3 def. 4 ghi 5 jkl 6 mno. Computers Rule the World

Lab 3: Embedded Systems

Video Game Engines. Chris Pollett San Jose State University Dec. 1, 2005.

SteamVR Unity Plugin Quickstart Guide

Tac Due: Sep. 26, 2012

GRADE 8 COMMUNICATIONS TECHNOLOGY

Better Gaming Experience by NVIDIA: Ansel, ShadowPlay Highlights and HDR Extensions. Jack ran, Henrik li Developer Technology Engineer

True bullet 1.03 manual

Next Back Save Project Save Project Save your Story

IMGD 1001: Programming Practices; Artificial Intelligence

A Machine Tool Controller using Cascaded Servo Loops and Multiple Feedback Sensors per Axis

Conversion of NC-code into a robot program

Development of Practical Software for Micro Traffic Flow Petri Net Simulator

DESIGN A SHOOTING STYLE GAME IN FLASH 8

Tac 3 Feedback. Movement too sensitive/not sensitive enough Play around with it until you find something smooth

Catch The Kites A Lightweight Android Game

IMGD 1001: Programming Practices; Artificial Intelligence

Capture the Flag Design Document Authors: Luke Colburn, Tyler Johnson, Chris LaBauve

MITOCW watch?v=ir6fuycni5a

Let s start by making a pencil, that can be used to draw on the stage.

Vocal Command Recognition Using Parallel Processing of Multiple Confidence-Weighted Algorithms in an FPGA

Recording guidebook This provides information and handy tips on recording vocals and live instruments at home.

2. There are many circuit simulators available today, here are just few of them. They have different flavors (mostly SPICE-based), platforms,

Vox s Paladins Spectator Mode Guide

Basic Tips & Tricks To Becoming A Pro

Mobile UNITY: Reasoning and Specification in Mobile Computing

MULTIPLAYER MOBILE GAMES (UNITY)

Brain Game. Introduction. Scratch

the gamedesigninitiative at cornell university Lecture 4 Game Grammars

6.111 Lecture # 19. Controlling Position. Some General Features of Servos: Servomechanisms are of this form:

Introduction. What do we mean by gameplay? AI World representation Behaviour simulation Physics Camera

BAFTA YGD Lesson plans

Unbreaking Immersion. Audio Implementation for INSIDE. Wwise Tour 2016 Martin Stig Andersen and Jakob Schmid PLAYDEAD

Fpglappy Bird: A side-scrolling game. Overview

To solve a problem (perform a task) in a virtual world, we must accomplish the following:

Usability Enhancements for the DVERT Simulator Architecture

Experiment 02 Interaction Objects

Interfacing ACT-R with External Simulations

OptimalVideoResume Help

the gamedesigninitiative at cornell university Lecture 23 Strategic AI

Programming with Scratch

Texas Hold Em Poker Unity Asset Store Project Multiplayer Version

Transcription:

Game Programming Paradigms Michael Chung

CS248, 10 years ago...

Goals

Goals 1. High level tips for your project s game architecture

Goals 1. High level tips for your project s game architecture 2. Some perspective on where Unity falls short

Outline 1. 2. 3. 4. Game loops and simulations Handling interactions Controls Entity component system

Outline 1. 2. 3. 4. Game loops and simulations Handling interactions Controls Entity component system

Game Loop Game loops handle all game simulation logic: - Add / remove entities Handle player inputs Update game logic systems Handle movement, physics and collisions Generate state for the view layer

Game Loop Game loops decouple your simulation timeline from: - User input Processor speed

Unity s Game Loop https://docs.unity3d.com/manual/executionorder.html

Unity s Game Loop Game logic in Update()? Worry less about view interpolation Couples simulation frequency with rendering loop

Unity s Game Loop Game logic in FixedUpdate()? In sync with physics loop Easier to reason with a discrete quantized timeline Your views will be jittery if you don t interpolate correctly

Unity s Game Loop What about ordering of behavior within game loop?

Unity s Game Loop

Unity s Game Loop

Unity s Game Loop

Unity s Game Loop You can order component priorities with a customized script execution order. But that means you are defining one ordering for: - Initialization Updates Teardown Not always convenient: - Hard to make sense of the merged ordering Maybe you want different orderings

Unity s Game Loop You may also have cyclical dependencies between components during your initialization steps. You could split components to solve this problem, but that may require you to update a lot of prefabs, and may increase coupling between components. You could split initialization code between Awake() and Start(), but that s really bad. A good way to solve this problem is to separate your behaviors from your state, and not use Unity s callbacks for most of your components.

Simulation Object that encapsulates loop and state

Simulation In Unity, there is one simulation running at all times. You have very little control over it: - You can t fast forward / rewind / replay You can t instantiate multiple simulations You can t differentiate initialization order from update order You can t define multiple initialization / update behaviors on the same component

Simulation You can solve all of these problems by creating your own simulation class.

Multiple Simulations

Multiple Simulations

Outline 1. 2. 3. 4. Game loops and simulations Handling interactions Controls Entity component system

Interaction Resolution

Interaction Resolution

Interaction Resolution

Interaction Resolution Slap!

Interaction Resolution

Interaction Resolution

Interaction Resolution

Interaction Resolution

Interaction Resolution

Interaction Resolution

Interaction Resolution

Interaction Resolution

Interaction Resolution

Interaction Resolution Do we care? Maybe. - Turn based simulations Competitive games Consistently biased small advantages can add up

Double buffering

Double buffering

Double buffering After swapping, instead of a buffer clear on the active buffer, we do a buffer copy. The buffer copy can be unnecessarily expensive: - Game states can be large Usually only a small portion of the game state changes each tick Potentially use this concept on pieces of state, or avoid it completely.

Message queues

Message queues

Message queues

Outline 1. 2. 3. 4. Game loops and simulations Handling interactions Controls Entity component system

Controls

Controls - Command Pattern

Controls - Command Pattern

Controls - Command Pattern

Controls - Input Handlers

Controls - Input Handlers

Controls - Input Handlers

Controls - Input with duration Some controls are kept activated. For example, holding a button down for movement.

Controls - Input with duration Could try this: - Activation command on key down Deactivation command on key up

Controls - Input with duration Could try this: - Activation command on key down Deactivation command on key up Couple problems: - Callbacks may be missed Conflicting controls could be a problem

Controls - Input with duration You could poll the input state, and keep track of input handler activation.

Controls - Input with duration

Controls - Input with duration

Controls - Input with duration

Controls - Input with duration

Controls - Input with duration Let s update our input handlers for Jump and Fire.

Controls - Input with duration Now add input handlers for moving left and right.

Controls - Simultaneous inputs What about conflicting controls? What happens when you press multiple buttons at the same time?

Controls - Simultaneous inputs

Controls - Simultaneous inputs

Controls - Simultaneous inputs

Controls - Simultaneous inputs

Controls - Simultaneous inputs

Controls - Simultaneous inputs

Controls - Simultaneous inputs Sometimes you want to handle only one input at a time out of a set of inputs.

Controls - Simultaneous inputs Sometimes you want to handle only one input at a time out of a set of inputs. Priority of input may be based on various factors: - How recent is the input? What are the gameplay effects of the input?

Controls - Simultaneous inputs Sometimes you want to handle only one input at a time out of a set of inputs. Priority of input may be based on various factors: - How recent is the input? What are the gameplay effects of the input? Are these relationships gameplay rules, or input rules?

Controls - Simultaneous inputs You can use state machines, not only for animation, but also for gameplay logic. In our movement system, you are either idle, moving left, or moving right.

Controls - Simultaneous inputs

Controls - Simultaneous inputs Let s examine our movement code again. Releasing one direction button could end movement in the opposite direction. We don t want that.

Controls - Simultaneous inputs Instead of requesting velocity modifications, we request state transitions.

Outline 1. 2. 3. 4. Game loops and simulations Handling interactions Controls Entity component system

Entity Component System (ECS) All interactive objects in your game are Entities. Each Entity is associated with a collection of Components. Plural quantities of certain types of Components may exist on an Entity.

Entity Component System (ECS)

Entity Component System (ECS)

Entity Component System (ECS)

Unity s ECS

Unity s ECS

Unity s ECS

Unity s ECS Two problems with Unity s ECS: - No view / model separation - Probably not a huge problem for your final projects Becomes a problem when you make a networked multiplayer game

Unity s ECS Two problems with Unity s ECS: - No view / model separation - - Probably not a huge problem for your final projects Becomes a problem when you make a networked multiplayer game No behavior / state separation - You can build this on top of Unity s system, by creating your own simulation code

Behavior and State Separation It may help to separate behaviors from state. Why? - Behaviors need to be organized and ordered in the game loop, but state does not. Modularization of behaviors is not clear if they are in the same class as the state.

Behavior and State Separation

Behavior and State Separation

Behavior and State Separation

Behavior and State Separation

Behavior and State Separation

Review

Review 1. Game loops and simulations a. b. c. Unity calls your code via callbacks, such as Awake(), Start(), FixedUpdate(), Update() You can customize the script execution order (be careful) Consider making a simulation class / component, to gain control

Review 1. Game loops and simulations a. b. c. 2. Unity calls your code via callbacks, such as Awake(), Start(), FixedUpdate(), Update() You can customize the script execution order (be careful) Consider making a simulation class / component, to gain control Handling interactions a. b. Double buffering Message queues

Review 1. Game loops and simulations a. b. c. 2. Handling interactions a. b. 3. Unity calls your code via callbacks, such as Awake(), Start(), FixedUpdate(), Update() You can customize the script execution order (be careful) Consider making a simulation class / component, to gain control Double buffering Message queues Controls a. b. Commands and input handlers Resolve conflicts in your gameplay logic, possibly by using state machines

Review 1. Game loops and simulations a. b. c. 2. Handling interactions a. b. 3. Double buffering Message queues Controls a. b. 4. Unity calls your code via callbacks, such as Awake(), Start(), FixedUpdate(), Update() You can customize the script execution order (be careful) Consider making a simulation class / component, to gain control Commands and input handlers Resolve conflicts in your gameplay logic, possibly by using state machines Entity component system a. b. Unity s ECS is very versatile You can write your own classes / components to extend it i. View / model separation ii. Behavior / state separation

Contact Happy to provide help on final projects and career planning! Reach out to me at mchung@pocketgems.com