Adam's Lair Forum
https://forum.adamslair.net:80/

TimeMult vs LastDelta
https://forum.adamslair.net:80/viewtopic.php?f=4&t=1222
Page 1 of 1

Author:  kiel814 [ 2018/01/07, 23:53 ]
Post subject:  TimeMult vs LastDelta

I am used to calculating speeds for objects using pixels/second.
Example:
I am using a resolution of 800 pixels and I want an object to take 2 seconds to cross the screen, I set it's speed to 400. Then on the update method I do something like:
Code:
Pos = Pos + Speed * deltaTime

Where deltaTime is usually a float which indicates (in seconds) how much time has passed since the last update.

Duality uses TimeMult instead, a multiplier that is 1.0f at 60 FPS and varies accordingly.
Now if I want an object to take 2 seconds to cross a 800 pixels wide screen, I have to convert that into standard frames:
60 * 2 = 120
then calculate the delta for each frame:
800 / 120 = 6.67
So I have to set my speed to 6.67 and do:
Code:
Pos = Pos + Speed * Time.TimeMult


I find all this very unintuitive, because 6.67 does not represent anything to me. Is it just me?
Time.LastDelta seems to represent what I'm looking for (in milliseconds), but it's help text advices against using this value for frame independent calculations. Why is that?

Author:  SirePi [ 2018/01/08, 09:45 ]
Post subject:  Re: TimeMult vs LastDelta

kiel814 wrote:
Time.LastDelta seems to represent what I'm looking for (in milliseconds),

yes it is, go for it!
kiel814 wrote:
but it's help text advices against using this value for frame independent calculations. Why is that?

my guess is that it means that the final calculations are made independently on the number of frames that it takes (i.e. as you said, move 400 pixels/second, idependently if it takes 60 frames or 20 to do so). That or a typo :mrgreen:

Author:  kiel814 [ 2018/01/14, 13:14 ]
Post subject:  Re: TimeMult vs LastDelta

Awesome! Thanks!

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/