Page 1 of 1
Do I need to worry about DTs greater than 1?
Posted: Fri Dec 25, 2020 2:57 am
by dizzykiwi3
I'm new to working with dt, and I was wondering if it made sense to ignore dt values greater than 1?
The reason is because it affects the math I'm attempting to do (maybe I should be trying different math)
For instance, to make a point approach a target:
point.x = target.x + (point.x-target.x)*.9
Can I assume that dt would not be greater than 1 ever? Could I do something like dt=math.min(1,dt)?
Thanks!
Re: Do I need to worry about DTs greater than 1?
Posted: Fri Dec 25, 2020 3:27 am
by Felix_Maxwell
It can be good to exclude long dt's because the dt just stacks up when certain things happen, for example if the window is grabbed and dragged. At the top of your update() function in your main.lua you could put:
Then it'll simply ignore/not do frames with huge [dt]. It's good to filter out those frames because like you said, crazy stuff can happen with the math while all of that time is piling up.
Re: Do I need to worry about DTs greater than 1?
Posted: Fri Dec 25, 2020 6:56 am
by ivan
dizzy, if your math any good it should still work even if delta is greater than 1
Your code for approaching a target does not use delta at all.
Re: Do I need to worry about DTs greater than 1?
Posted: Fri Dec 25, 2020 1:39 pm
by pgimeno
Rather than assuming it won't, or ignore too big ones, I would cap it. It is frequent and desirable to cap dt to a reasonable value. See e.g.
https://gamedev.stackexchange.com/quest ... delta-time
Note also that the speed with the damping formula you've mentioned varies with frame rate. To make it independent of the frame rate, use math.exp(-dt*something) instead of 0.9. See
http://www.rorydriscoll.com/2016/03/07/ ... sing-lerp/
Re: Do I need to worry about DTs greater than 1?
Posted: Sun Dec 27, 2020 7:21 pm
by dizzykiwi3
Ah, perfect! What a great read, many thanks y'all!