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!
Do I need to worry about DTs greater than 1?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- dizzykiwi3
- Citizen
- Posts: 58
- Joined: Tue Jan 14, 2014 2:03 am
- Felix_Maxwell
- Prole
- Posts: 24
- Joined: Wed Dec 04, 2019 3:15 pm
Re: Do I need to worry about DTs greater than 1?
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.
Code: Select all
if dt > 0.075 then return end
Re: Do I need to worry about DTs greater than 1?
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.
Your code for approaching a target does not use delta at all.
Re: Do I need to worry about DTs greater than 1?
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/
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/
- dizzykiwi3
- Citizen
- Posts: 58
- Joined: Tue Jan 14, 2014 2:03 am
Re: Do I need to worry about DTs greater than 1?
Ah, perfect! What a great read, many thanks y'all!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/
Who is online
Users browsing this forum: No registered users and 7 guests