From what I understand about time based Euler Integration is that you will set a number of pixels you want your object to move in the space of second and then the value will be regulated based on the frame-rate of the machine your running the game on.

What I'm having issue with is this

 You will set your acceleration

 acceleration = 30;

Then that acceleration will be added to the velocity and multiplied by the time which would be say 0.0166667 if the frame-rate is 60fps which will cut down the velocity to the appropriate number for that frame which would be 0.50001

velocity += acceleration * dt;

but then when you add the velocity to the position it yet again multiplies the result by 0.0166667 which leaves you with 0.0833366667

position += velocity * dt;

What I'm trying to get is that instead of the 30 pixels per second I initially intended for the character to move I will need to put in an acceleration value of 1800.

I was wondering why this is done instead of simply multiplying the acceleration by the dt and leaving it at that ?

  • 1
    \$\begingroup\$ If you have a dt variable then it is not a fixed timestep. Fixed timestep is when the game logic is guaranteed to run a certain number of times per second, so you don't have to worry about dt (i.e. dt is constant). \$\endgroup\$ – Ricket Jan 12 '12 at 14:09

Acceleration is in units per second per second; it is the change in velocity over time. So you have to multiply it by time to get the change in velocity (units per second).

Similarly, velocity is in units per second; it is the change in position over time. So you have to multiply it by time to get the change in position (units).

You are not multiplying something by dt twice; you are multiplying the acceleration by dt to get the velocity change and adding it to velocity, then multiplying the velocity by dt to get the position change and adding it to position.

  • \$\begingroup\$ Correct. This usually works like something.x += (something.velocity * fractionalSecondsSinceLastUpdate). \$\endgroup\$ – ashes999 Jan 12 '12 at 14:23

First you should understand that fixed time step is really much simpler than variable time step. If you like you can throw away dt completely, then your numbers will simply be per time step rather than per second.

Actually the only reason for including a dt in your code is that it makes it easy to change the update frequency while keeping everything else mostly constant.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.