physics solutions for innovative game design

49
Physics Solutions for Innovative Game Design Give your iPhone games a dynamic real-world feel by integrating a physics engine. Andrei Gradinari Lead Engineer - Backflip Studios Tom Blind Lead Designer - Backflip Studios

Upload: john-wilker

Post on 18-May-2015

5.178 views

Category:

Technology


2 download

DESCRIPTION

Give your iPhone games a dynamic real-world feel by integrating a physics engine. This session will give an overview of the current physics engines available for iPhone development, discussing the pros and cons of each. We will also discuss how to decide if a physics engine is right for your project or you are better off with custom code. We'll dive into some real world examples with Ragdoll Blaster which uses the Open Dynamics Engine and talk about optimization, debugging and other tips and tricks.

TRANSCRIPT

Page 1: Physics Solutions for Innovative Game Design

Physics Solutions for Innovative Game Design

Give your iPhone games a dynamic real-world feel by integrating a physics engine.

Andrei GradinariLead Engineer - Backflip Studios

Tom BlindLead Designer - Backflip Studios

Page 2: Physics Solutions for Innovative Game Design

History of Physics in Gamesand

"Physics Games"

Page 3: Physics Solutions for Innovative Game Design

History of Physics in GamesVery simple physics (Late 80-s to Early 90-s) - Racing games, flight sims, mini golf games, etc ...

Page 4: Physics Solutions for Innovative Game Design

History of Physics in GamesSimple real physics (Middle - Late 90-s) - NFS 1, Unreal, Half-Life, many others

Page 5: Physics Solutions for Innovative Game Design

History of Physics in GamesSimple real physics (Middle - Late 90-s) - NFS 1, Unreal, Half-Life, many others

Page 6: Physics Solutions for Innovative Game Design

History of Physics in GamesSimple real physics (Middle - Late 90-s) - NFS 1, Unreal, Half-Life, many others

Page 7: Physics Solutions for Innovative Game Design

History of Physics in GamesComplex real physics (Early 2000s) - Half-Life 2

Page 8: Physics Solutions for Innovative Game Design

History of Physics in GamesComplex real physics (Early 2000s) - Half-Life 2

Page 9: Physics Solutions for Innovative Game Design

History of Physics in GamesComplex real physics (Early 2000s) - Half-Life 2

Page 10: Physics Solutions for Innovative Game Design

History of Physics in GamesComplex real physics (Early 2000s) - Prey

Page 11: Physics Solutions for Innovative Game Design

Prey: Flip Gravity Gameplay Mechanic(how to get to the box with candy)

Page 12: Physics Solutions for Innovative Game Design

Prey: Flip Gravity Gameplay Mechanic(how to get to the box with candy)

Page 13: Physics Solutions for Innovative Game Design

Prey: Flip Gravity Gameplay Mechanic(how to get to the box with candy)

Page 14: Physics Solutions for Innovative Game Design

History of Physics in GamesPhysics on GPUs: Almost real world complexity (Middle to Late 2000's)Crysis engine 3000 Barrels, real time:

Page 15: Physics Solutions for Innovative Game Design

History of Physics in GamesPhysics on GPUs: Almost real world complexity (Middle to Late 2000's)

Page 16: Physics Solutions for Innovative Game Design

What is a Physics Game?

Page 17: Physics Solutions for Innovative Game Design

These are NOT physics gamesEven though they use physics

Doom 3 Unreal

What is a Physics Game?

Page 18: Physics Solutions for Innovative Game Design

These are physics games!

Crayon Physics Fantastic Contraption

What is a Physics Game?

Page 19: Physics Solutions for Innovative Game Design

Physics EngineDefinition and How It Works

Page 20: Physics Solutions for Innovative Game Design

Physics Engine

A physics engine is a set of functions that lets you describe layout of your system of physics objects and then tells you how the state of this system changes over time.

Page 21: Physics Solutions for Innovative Game Design

Physics EngineDefine layout of your system of objects (shapes, positions, masses, dimensions, global gravity vector, etc...)

Page 22: Physics Solutions for Innovative Game Design

Physics EngineThe engine tells you how your system changes over time

Page 23: Physics Solutions for Innovative Game Design

Physics SimulationThe process handled by a physics engine that figures out what happens to the given set of objects over a certain period of time is called physics simulation

->Simulation->

Page 24: Physics Solutions for Innovative Game Design

Can be:Not Interactive (user input is not taken in consideration)

Interactive (user input affects the simulation). Interactive simulations are used in most games

Physics Simulation

Page 25: Physics Solutions for Innovative Game Design

Do you need a physics engine?

Page 26: Physics Solutions for Innovative Game Design

Sometimes, it's easier to do it yourself!

Less memory & CPU usageLess disk spaceLess time spent linking librariesSimpler, if you don't need anything fancy

Do you need a physics engine?

Page 27: Physics Solutions for Innovative Game Design

Rolling your own physics:

acceleration = force / massThings get trickier with collisions...

Do you need a physics engine?

Page 28: Physics Solutions for Innovative Game Design

The Physics of Paper TossForces are one-dimensional

Add flick force and wind force to determine landing point

Animate to make it look pretty

No physics library needed!

Page 29: Physics Solutions for Innovative Game Design

Typical Physics Engine

Page 30: Physics Solutions for Innovative Game Design

Consists of:

Rigid Body Dynamics Simulation Engine

Collision Detection Engine

Typical Physics Engine

Page 31: Physics Solutions for Innovative Game Design

Building blocks of your physics world:Geometric Shapes (describe what your objects look like)

Joints (describe how your objects are connected to each other)

Typical Physics Engine

Page 32: Physics Solutions for Innovative Game Design

Typical Physics Engine

Collision contact points generation (collision detection engine)

Creating temporary joints based on contact points, and attaching them to respective physics objects

Performing actual simulation step (rigid body dynamics engine)

Simulation Step:

Page 33: Physics Solutions for Innovative Game Design

Simple Simulation Example (Step 1)

Page 34: Physics Solutions for Innovative Game Design

Simple Simulation Example (Step 2)

Page 35: Physics Solutions for Innovative Game Design

Simple Simulation Example (Step 3)

Page 36: Physics Solutions for Innovative Game Design

Performance Tips and Tricks

Page 37: Physics Solutions for Innovative Game Design

Keep things simpleMore objects in your physics simulation = more time spent to simulate the system = lower framerate as a result.

Approximate complex volumes with sets of simple volumes

Performance gain is well worth it.User will never see the difference, as long as you do it right. It's still fine to render fully detailed models, while simulating simple shapes on the physics side.

Performance Tips and Tricks

Page 38: Physics Solutions for Innovative Game Design

Example of complex volumes approximation.Rendered models:

Performance Tips and Tricks

Page 39: Physics Solutions for Innovative Game Design

Example of complex volumes approximation.Simulated shapes:

Performance Tips and Tricks

Page 40: Physics Solutions for Innovative Game Design

Performance Tips and TricksDo not simulate static objects

They should never be simulated in Rigid Bodies Dynamics Engine, because they never move.

Do not simulate dynamic objects that are stationary at the moment.

ODE, for example, automatically does this for you. It is called Auto Disable.

Use spatial partitioning

Setup collision detection engine to generate as few contact points as possible

Page 41: Physics Solutions for Innovative Game Design

Several small steps vs one large step

Several small steps:

More realistic simulation, especially when simulating dynamically changing forces

Less problems with objects flying through each other.

One large step:

Less realistic simulation

Better performance

Performance Tips and Tricks

Page 42: Physics Solutions for Innovative Game Design

Probable instability problems with simulation and their causes:

Large simulation step

Large forces applied to bodies

Large masses, especially when mixed with small masses

High speeds of the objects

Fast spinning objects

High friction

Performance Tips and Tricks

Page 43: Physics Solutions for Innovative Game Design

A Brief Comparison of Physics Engines Used on the iPhone

2DBox2DChipmunk

3DODEBullet

Page 44: Physics Solutions for Innovative Game Design

Box2DOptimized for 2D gamesWorks well with cocos2dUsed in many iPhone games such as Crayon Physics and Rolando

Comparison of Physics Engines

Page 45: Physics Solutions for Innovative Game Design

ChipmunkVery lightweightWritten in pure CMade by the creators of Crayon Ball for the iPhone"Makes you smarter, stronger, and more attractive to the opposite gender!"

Comparison of Physics Engines

Page 46: Physics Solutions for Innovative Game Design

Open Dynamics Engine (ODE)Industry veteranSupports full 3D simulationFast, even on the iPhoneUsed in Touchgrind and Ragdoll Blaster

Comparison of Physics Engines

Page 47: Physics Solutions for Innovative Game Design

Bullet Physics LibraryComparison of Physics Engines

Highly optimized for many architecturesMulti-threadedThird most popular physics library according to survey by Game Developer Magazine (Aug. 2009)Used by Oolong Engine (Kids vs. Zombies, iPhysics)

Page 48: Physics Solutions for Innovative Game Design

Contemporary physics in games on consoles and PC's = the nearest future of physics in mobile games...

Page 49: Physics Solutions for Innovative Game Design

[email protected]

Thanks!