Do I need to worry about DTs greater than 1?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
dizzykiwi3
Citizen
Posts: 58
Joined: Tue Jan 14, 2014 2:03 am

Do I need to worry about DTs greater than 1?

Post 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!
User avatar
Felix_Maxwell
Prole
Posts: 24
Joined: Wed Dec 04, 2019 3:15 pm

Re: Do I need to worry about DTs greater than 1?

Post 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:

Code: Select all

if dt > 0.075 then return end
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.
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Do I need to worry about DTs greater than 1?

Post 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.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: Do I need to worry about DTs greater than 1?

Post 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/
User avatar
dizzykiwi3
Citizen
Posts: 58
Joined: Tue Jan 14, 2014 2:03 am

Re: Do I need to worry about DTs greater than 1?

Post by dizzykiwi3 »

pgimeno wrote: Fri Dec 25, 2020 1:39 pm 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/
Ah, perfect! What a great read, many thanks y'all!
Post Reply

Who is online

Users browsing this forum: No registered users and 48 guests