cs248 lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/cs248_lecture_10.pdf ·...
TRANSCRIPT
![Page 1: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/1.jpg)
CS248 Lecture 10
February 9th, 2017
S IMULAT ION ( AND OTHER STUFF ) I N UNI T Y
![Page 2: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/2.jpg)
Overview§ Physics
› Rigid Body› Wheels› Cloth› Fracture (not covered in live demo)
§ Particle Systems§ Navigation (not covered in live demo)
![Page 3: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/3.jpg)
Physics
J U S T C A U S E 2 4 8
![Page 4: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/4.jpg)
Rigid Body
Stereotypical Barrel Drop Physics Test (UE3)
![Page 5: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/5.jpg)
Rigid Body
Cow Boosting (Just Cause 3)
![Page 6: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/6.jpg)
Rigid Body§ Use Unity Rigid Bodies (http://docs.unity3d.com/ScriptReference/Rigidbody.html)
› Your GameObject should have some collider attached (box, capsule, mesh, sphere, etc.)› Give it a PhysicMaterial (http://docs.unity3d.com/Manual/class-PhysicMaterial.html) to change
how rigid bodies interact.§ How to move your rigid bodies? With forces! (Don’t forget: 𝐹 = 𝑚𝑎 )
› Constant Force: http://docs.unity3d.com/Manual/class-ConstantForce.html› RigidBody also has ‘AddForce/Torque’ functions:
• AddForce: http://docs.unity3d.com/ScriptReference/Rigidbody.AddForce.html• AddForceAtPosition:
http://docs.unity3d.com/ScriptReference/Rigidbody.AddForceAtPosition.html• AddExplosionForce:
http://docs.unity3d.com/ScriptReference/Rigidbody.AddExplosionForce.html (because what good is physics if you can’t do explosions)
§ Don’t use the C++ plugin rigid bodies (unless you really, really, really want to).
![Page 7: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/7.jpg)
Rigid Body Constraints§ Use Unity joints (character joints, fixed joints, hinge joints, etc.).
Euphoria Engine Ragdoll
![Page 8: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/8.jpg)
Wheels§ Use wheel collider: http://docs.unity3d.com/Manual/class-WheelCollider.html§ You can now move your vehicle by applying forces (or braking) to your wheels
Need For Speed 2015 Racing
![Page 9: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/9.jpg)
Cloth§ Use Unity’s provided cloth component: http://docs.unity3d.com/Manual/class-Cloth.html§ Your cloth won’t be perfect – it will intersect with things in the world and that’s okay.
Assassin’s Creed Unity Cloth
![Page 10: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/10.jpg)
Fracture§ Unity does not come with a built-in fracture system (UE4 does). Plugins exist (mainly non-free ones).§ But the concept is fairly simple (implementation not so much):
› Start off with a static mesh (i.e. a pillar).› Upon hitting the mesh with a force (i.e. with a ball), split the entire mesh (or just part of the mesh)
using an algorithm (pre-generated or on the spot).• “Real Time Dynamic Fracture with Volumetric Approximate Convex Decompositions” -
http://matthias-mueller-fischer.ch/publications/fractureSG2013.pdf› Apply forces to the fractured mesh pieces as necessary (i.e using the rigid body techniques from
earlier)
Battlefield 4 Levolution
![Page 11: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/11.jpg)
Particle SystemsW H A T G O O D A R E
E X P L O S I O N S I F T H E Y ’ R E N O T
P R E T T Y
![Page 12: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/12.jpg)
Particle Systems
Metal Gear Solid 5 Explosion
![Page 13: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/13.jpg)
Particle Systems
Counter Strike Global Offensive Muzzle Flash
![Page 14: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/14.jpg)
Particle Systems§ Particle systems transform according to rules that you give it:
› Initial velocity, velocity over time, size over time, etc.› You also control number of particles to spawn, when they spawn, when they stop spawning,
etc.§ Particle system is just a bunch of points moving in space.§ Rendered using textures (each particle gets the same texture).
› Can use a texture atlas to give particle system the illusion of changing over time (i.e. going from fire to smoke).
§ Free particle textures available on the asset store (you will probably find it hard to make your own)!
![Page 15: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/15.jpg)
NavigationU S U A L L Y E A S I E R
T H A N D R A W I N G P A T H S
![Page 16: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/16.jpg)
NavMesh§ Unity contains a NavMesh system: http://docs.unity3d.com/Manual/Navigation.html§ NavMesh concept
› As a preprocess step, figure out where a character could potentially move to/can not move to (can have different “agents” that represent different character types).
› At runtime, use an “agent” that queries the NavMesh to get the path to get from point A to point B.
› You can use the path to do more than just moving a AI character.
Skyrim Clairvoyance Spell (Show Path to Objective)
![Page 17: CS248 Lecture 10 - web.stanford.eduweb.stanford.edu/class/cs248/pdf/CS248_Lecture_10.pdf · Assassin’s Creed Unity Cloth. ... › Apply forces to the fractured mesh pieces as …](https://reader033.vdocuments.net/reader033/viewer/2022052712/5b79d2877f8b9a331e8eb812/html5/thumbnails/17.jpg)
Live DemoC R E A T I N G
J U S T C A U S E 2 4 8