physics solutions for innovative game design
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/1.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/2.jpg)
History of Physics in Gamesand
"Physics Games"
![Page 3: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/3.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/4.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/5.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/6.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/7.jpg)
History of Physics in GamesComplex real physics (Early 2000s) - Half-Life 2
![Page 8: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/8.jpg)
History of Physics in GamesComplex real physics (Early 2000s) - Half-Life 2
![Page 9: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/9.jpg)
History of Physics in GamesComplex real physics (Early 2000s) - Half-Life 2
![Page 10: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/10.jpg)
History of Physics in GamesComplex real physics (Early 2000s) - Prey
![Page 11: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/11.jpg)
Prey: Flip Gravity Gameplay Mechanic(how to get to the box with candy)
![Page 12: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/12.jpg)
Prey: Flip Gravity Gameplay Mechanic(how to get to the box with candy)
![Page 13: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/13.jpg)
Prey: Flip Gravity Gameplay Mechanic(how to get to the box with candy)
![Page 14: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/14.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/15.jpg)
History of Physics in GamesPhysics on GPUs: Almost real world complexity (Middle to Late 2000's)
![Page 16: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/16.jpg)
What is a Physics Game?
![Page 17: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/17.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/18.jpg)
These are physics games!
Crayon Physics Fantastic Contraption
What is a Physics Game?
![Page 19: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/19.jpg)
Physics EngineDefinition and How It Works
![Page 20: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/20.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/21.jpg)
Physics EngineDefine layout of your system of objects (shapes, positions, masses, dimensions, global gravity vector, etc...)
![Page 22: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/22.jpg)
Physics EngineThe engine tells you how your system changes over time
![Page 23: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/23.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/24.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/25.jpg)
Do you need a physics engine?
![Page 26: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/26.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/27.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/28.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/29.jpg)
Typical Physics Engine
![Page 30: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/30.jpg)
Consists of:
Rigid Body Dynamics Simulation Engine
Collision Detection Engine
Typical Physics Engine
![Page 31: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/31.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/32.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/33.jpg)
Simple Simulation Example (Step 1)
![Page 34: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/34.jpg)
Simple Simulation Example (Step 2)
![Page 35: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/35.jpg)
Simple Simulation Example (Step 3)
![Page 36: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/36.jpg)
Performance Tips and Tricks
![Page 37: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/37.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/38.jpg)
Example of complex volumes approximation.Rendered models:
Performance Tips and Tricks
![Page 39: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/39.jpg)
Example of complex volumes approximation.Simulated shapes:
Performance Tips and Tricks
![Page 40: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/40.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/41.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/42.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/43.jpg)
A Brief Comparison of Physics Engines Used on the iPhone
2DBox2DChipmunk
3DODEBullet
![Page 44: Physics Solutions for Innovative Game Design](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/44.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/45.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/46.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/47.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022052619/555a0a2bd8b42a76498b45a0/html5/thumbnails/48.jpg)
Contemporary physics in games on consoles and PC's = the nearest future of physics in mobile games...