Math for Game Programmers: Building a Better Jump

preview_player
Показать описание
In this 2016 GDC talk, Minor Key Games' Kyle Pittman shows how to construct natural-feeling jump trajectories from designer-friendly input like desired height and distance, modeled programmatically using one of a few available integration methods.

GDC talks cover a range of developmental topics including game design, programming, audio, visual arts, business management, production, online games, and much more. We post a fresh GDC video every weekday. Subscribe to the channel to stay on top of regular updates, and check out GDC Vault for thousands of more in-depth talks from our archives.

Follow us on Twitter

Check out our Facebook page for GDC exclusives

Рекомендации по теме
Комментарии
Автор

Clicked on this to watch a GDC talk about video game mechanics, ended up essentially watching a refresher lecture that I remember taking during first year Physics

Table
Автор

25:13 Kind of uncool forcing him out the podium.

NeoAF
Автор

Short note on the integration methods:
Euler integration doesn't conserve energy, so what happens is that when we try to approximate a continuous jump curve, in each discrete time step we will travel in a straight line in the same direction as (tangent to) the curve. Over many time steps, the error from choosing a straight line will accumulate and deviate from the "real" curve. Depending on how you do your update function and how it depends on each frame, a frame rate drop might make this error more noticeable.
Runge-Kutta 4 is very accurate but also doesn't conserve energy, but the error grows very slow and won't be noticeable during a single jump. However, it is a bit expensive to calculate.
And then comes Verlet, which is cheaper than RK4 and conserves energy. The accuracy depends on the timestep though, so it probably won't be as accurate as RK4, but it generally works better in games.

Ermude
Автор

Worth noting that Mario switches to heavy gravity on jump release even if peak hasn't been reached yet, giving you jump height control. That was the original reason for it to be coded that way. But in general, yeah, having acceleration change on up and down movement and with jump key held/released tends to give the nice responsive jumps you see in the platformers we tend to remember. And the specifics of what gravity should be on each segment and whether pressing the jump key again after releasing it makes a difference is up to specific game implementation.

konstantinkh
Автор

Is there an extreme stereo effect on this video or is it just me? If he moves two inches to the right, his voice gets almost completely panned to the right channel, idem for left channel. I wonder if this was recorded with two mics on stereo channels (WHY?!) or the person who did the edit of this video was just bored to hell and decided to pan the speaker's voice each time he moved just a little tiny bit.

gordorodo
Автор

if you are using unity, Sebastian lague have a great tutorial & source code available that does this
just search for
" [Unity] Creating a 2D Platformer (E03. jump physics) "

mrslake
Автор

4:25, 9:48, 12:58, 16:25, 19:58, 22:37, 25:18

echelonk
Автор

Bro, that guy was so rude to the guy speaking. Watch till the end to see who deserves the 2016 douche award.

jayxofficial
Автор

I wish I had known GDC had their own youtube channel sooner. This is great. Getting passed the crappy audio, I sat through this entire lecture and both facepalmed at how close I actually got to something similar to this on my own, and learned a great deal at the same time.

sirgouki
Автор

Just happened on this video. As someone who tried to fix the, "floatyness" of UE4's standard jump back in school it was a really interesting talk.

manwithbrisk
Автор

I guess sometimes we keep up with the advanced stuff and forget about the basics... I really needed all that Physics Introduction review. Thank you, Kyle!!

viniciusqueiroz
Автор

Really liked the talk, many thanks! Also, downloaded the game, liked it too :) Jumping felt great - clearly know what you're talking about :)

harborned
Автор

Nice to see Leonard Hofstadter doing science talks again.

Estigy
Автор

Parabolics completely smoothed out my moving platform code. I was looking for good parabolic integration over the Euler method I was using and found it! Thank you.

nightwintertooth
Автор

boy I wish I had more than middle school level math knowledge

zoeythebee
Автор

Here's my resulting code after watching this and the tutorial series "[Unity] Creating a 2D Platformer" mentioned below. Hopefully this will be useful for someone.

// Calculate the gravity and initial jump velocity values
_jumpGravity = -(2 * JumpHeight) / Mathf.Pow(TimeToJumpHeight, 2);
_jumpVelocity = Mathf.Abs(_jumpGravity) * TimeToJumpHeight ;

// Step update
stepMovement = (_velocity + Vector3.up * _gravity * Time.deltaTime * 0.5f) * Time.deltaTime;

_velocity.y += _gravity * Time.deltaTime;

// When jump button pressed,
_velocity.y = _jumpVelocity;

NB. that is for a simple jump, no double jumping, differing gravity when descending, etc. Those things should be trivial to solve; the meat of the 'better jump' is calculating velocity/gravity from a desired height variable and time to reach it variable, and implementing the "velocity verlet" when calculating the step movement (+ gravity * deltaTime * 0.5). I wish I understood the math behind this stuff a bit better, but just knowing how to implement it is good enough for my purposes.

merkaba
Автор

This is a superb, superb tutorial. Thanks Kyle!

nucleartide
Автор

Wow learned more about physics from this than high school...

louther
Автор

I learned about the Verlet algorithm while doing Molecular Dynamics. I'm surprised to see it applied to videogames. :-)

MarcCastellsBallesta
Автор

Excellent treatment of this material. You Have To Win The Game looks fun and nostalgic also.

taylorbird