Simple Verlet Physics by Stuart Allen (FunkyPear)


Published on

Stuart Allen instructs how to utilize verlet physics for more elegant motion in games.

1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Simple Verlet Physics by Stuart Allen (FunkyPear)

  1. 1. Simple Verlet Physics for Games Stuart Allen (aka FunkyPear)
  2. 2. Euler Integration Simplest method of moving particles and objects Need to keep track of object position and speed Each frame/time step add speed to position: X = X + speedX Y = Y + speedY
  3. 3. Euler Integration
  4. 4. Verlet Integration Also fairly simple, but expandable to be more accurate (outside scope of this talk) Need to keep track of object current position and previous position Each frame/time step, calculate distance travelled since last time, and add to current position: X = X + (X - oldX) Y = Y + (Y - oldY)
  5. 5. Verlet Integration
  6. 6. Demo 1Euler & Verlet Particle Movement Demo
  7. 7. Constraints Constraints ensure two particles stay a certain distance apart by moving them towards or away from each other
  8. 8. Demo 2Particle Constraint Demo
  9. 9. Gravity & Other Forces Forces applied directly to particle positions  Gravity: y += 1 Verlet motion makes force persist (inertia)
  10. 10. Demo 3Particle Constraint with Gravity Demo
  11. 11. Simple Four Step Verlet EngineStep 1: Apply forces (gravity, wind, etc)Step 2: Verlet updateStep 3: ConstraintsStep 4: Collision Detection
  12. 12. Rope Expanding from our last demo, rope can be simulated by having a chain of points connected in row with sticks
  13. 13. Demo 4Multiple Constraints Rope Demo
  14. 14. Cloth Cloth can be simulated by a grid of points that are connected to their neighbours
  15. 15. Demo 5Rope Becomes Cloth Demo
  16. 16. Relaxation Loop over constrain step multiple time to pull points together and make final result more rigid Less constrain loops means a more bendy and bouncy structure
  17. 17. Engine Upgrade: Fixed Points Fixed points do not move – other end of stick does all the moving
  18. 18. Structures & Towers Adding fixed points allows us to build fixed but flexible structures  Towers (fixed points on ground)  Bridges (fixed points on either edge of a gap)  Dangling ropes (fixed point above rope)
  19. 19. Structures & Towers
  20. 20. Demo 6Towers Editor Demo
  21. 21. Demo 7Game Jam Tower Game Demo
  22. 22. Similar Mechanic:World of Goo (2D Boy)
  23. 23. Engine Upgrade: Stick Length Tolerance Sticks previously had set length Modify sticks to have min and max lengths. Soft body dynamics possible due to addition valid solutions
  24. 24. Blobs Blobs attempt to mimic gooey / gelatinous objects Multiple different configurations:  Centre point makes blob seem more solid  Double skinning helps stop edge points glitching  More tolerance in inner sticks makes for a flatter, more dynamic blob
  25. 25. Demo 8Blobs Editor Demo
  26. 26. Blobs – Each Point Linked to Opposite
  27. 27. Blobs – With Central Point
  28. 28. Similar Mechanic:Gish (Chronic Logic)
  29. 29. Thanks for listening! :) More info and source code