Trying to make a game entity jump. Can't figure out what is dt?

At it's core what is delta time? In every equation to make a player jump I see that it is multiplied by delta time. Is this a constant value or a changing one? How does this value help? I don't understand why it's needed for velocity, acceleration and jumping.

Delta time is the time elapsed since the previous frame.

It can be a constant value but is not required to be; typically it will be dependent on factors including, but not limited to:

• how fast your hardware is,
• whether or not you have vsync enabled,
• what your monitor's refresh rate is,
• whether your program is framerate limited or not,
• etc.

It's important because otherwise movement would be done at a rate that is framerate-dependent: if your program was running at a faster framerate then movement would likewise be faster.

Great answer by 'Le Comte du Merde-fou'.

Small practical pseudo-code example:

game(){
previousTime = systemTime.now() // initial time

//gameloop
while(){

currentTime = systemTime.now() // current time
dt = currentTime - previousTime // difference between current and previous time
previousTime = currentTime //save the current time to be used to calculate dt for the next cycle

update(dt)
//render etc...
}
}

• The thing is, the framework I'm using lets you set the fps in the gameloop and then it only runs the loop that many times per second. So if i had an update() function in the loop, and i had set the framerate to 60fps, it would be run exactly 60 times per second. So if that's the case, then would I even need to calculate dt and pass it in as a parameter? – Ivan Lendl Sep 8 '17 at 4:14
• @Ivan-Lendl In that case dt would always be (1/60). But depending on the hardware the game is run on, frames might be finished faster or slower than this time. If they are finished faster, one solution is to delay the next update until the correct amount of time has passed. If it is run slower one solution is to skip frames. It is possible to ensure that we never run at >60 fps but it is not possible to ensure that we never run at <60 fps since it will depend on your code and the hardware it runs on – George Hanna Sep 8 '17 at 7:36
• @Ivan-Lendl You could set dt as a parameter with a constant value or better yet not even use it at all if you know that the game will always run at 60fps. The game might behave differently on hardware that isnt able to run it at 60 fps though – George Hanna Sep 8 '17 at 7:43