1 / 43

Building a Better Jump J. Kyle Pittman @ PirateHearts Co-founder, Minor Key Games

Building a Better Jump J. Kyle Pittman @ PirateHearts Co-founder, Minor Key Games. Hi. I’m Kyle Hi Kyle. 2007-2013. 2013-20XX. Motivation. Avoid hardcoding , guessing games Design jump trajectory on paper Derive constants to model jump in code. Motivation.

robina
Download Presentation

Building a Better Jump J. Kyle Pittman @ PirateHearts Co-founder, Minor Key Games

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Building a Better JumpJ. Kyle Pittman@PirateHeartsCo-founder, Minor Key Games

  2. Hi • I’m Kyle • Hi Kyle 2007-2013 2013-20XX

  3. Motivation • Avoid hardcoding, guessing games • Design jump trajectory on paper • Derive constants to model jump in code

  4. Motivation • Has this ever happened to you? • There’s GOT to be a better way!!

  5. Assumptions • Model player as a simple projectile • Game state • Position, velocity integrated on a timestep • Acceleration from gravity • No air friction / drag

  6. Gravity • Single external force • Constant accelerationover time

  7. Integration • Integrate over timeto find velocity

  8. Integration • Integrate over timeagain to find position

  9. Projectile motion • Textbox Physics 101 projectile motion • Understand how we got there

  10. Parabolas • Algebraic definition • Substituting

  11. Properties of parabolas • Symmetric

  12. Properties of parabolas • Geometric self-similarity

  13. Properties of parabolas • Shaped by quadratic coefficient

  14. Design on paper

  15. Design on paper

  16. Maths • Derive valuesfor gravity andinitial velocityin terms ofpeak height andduration to peak

  17. Initial velocity Solve for v0:

  18. Solve for g: Gravity Known values:

  19. Solve for v0: Back to init. vel.

  20. Review

  21. Time  space • Design with x-axis as distance in space • Introduce lateral (foot) speed • Keep horizontal and vertical velocity components separate

  22. Parameters

  23. Time  space

  24. Time  space

  25. Maths • Rewrite gravity and initial velocity in terms of foot speed and lateral distanceto peak of jump

  26. Maths

  27. Review

  28. Breaking it down • Real world: Projectiles always follow parabolic trajectories. • Game world: We can break the rules in interesting ways. • Break our path into a series of parabolic arcs of different shapes.

  29. Breaks • Maintain continuityin position and velocity • Trivial in implementation • Choose a new gravityto shape our jump

  30. Fast falling Position Velocity / Acceleration

  31. Variable height jumping Position Velocity / Acceleration

  32. Double jumping Position Velocity / Acceleration

  33. Integration • Put our gravity and initial velocity constants to use in practice • Integrate from a past state to a future state over a time step

  34. Integration

  35. Euler • Pseudocodepos += vel * Δtvel += acc * Δt • Easy • Unstable • We can do better

  36. Runge-Kutta (RK4) • The “top-shelf” integrator. • No pseudocode here. :V • Gaffer on Games: “Integration Basics” • Too complex for our needs.

  37. Velocity Verlet • Pseudocodepos += vel*Δt + ½acc*Δt*Δtnew_acc = f(pos)vel += ½(acc+new_acc)*Δtacc = new_acc

  38. Observations • Similarity to projectile motion formula • What if our acceleration were constant? • We could integrate with 100% accuracy

  39. Assuming constant acceleration

  40. Assuming constant acceleration • Pseudocodepos += vel*Δt + ½acc*Δt*Δtvel += acc*Δt • Trivially simple change from Euler • 100% accurate as long as our acceleration is constant

  41. Near-constant acceleration • What if we don’t change a thing? • The error we accumulate when our acceleration does change (versus Velocity Verlet) will be: • Δacc * Δt * Δt • Acceptable?

  42. The takeaway • Design jump trajectories as a series of parabolic arcs • Can author unique game feel • Trust result to feel grounded in physical truths

  43. Questions? • In practice: You Have to Win the Game (free game PLAY IT PLAY MY THING) • The Twitters: @PirateHearts • http://minorkeygames.com • http://gunmetalarcadia.com

More Related