How can I calculate speed based on previous speed?

2 replies · 2K views · last reply
Tim Leijten
Messages
28
Reaction score
1
Hi,

I am developing a Train Simulator kind of program where I calculate speed each frame.
I currently do that by:
Speed = (f/m)*elapsed frames*time between frames
This works, but goes wrong when there are framerate drops or if the force changes, that's why i want to calculate the speed with the speed in the previous frame, and the time a frame took to complete.
Can someone help me with calculating speed based on the previous speed and time between frames?Thanks
 
russ_watters said:
It's just a minor revision of the equation you have:
Speed = (f/m)*time between frames+ previous speed
Thank you!
 
  • Like
Likes   Reactions: russ_watters