Hi,
I’m looking for a way to ensure the delta time won’t be longer than a specific threshold.
This is important because I notice that while receiving an email while my game is running the FPS drops, and the dt
in all of the update methods is very large, causing my player to die.
How can I limit it in a way that all of the update methods will get my capped dt?
Thanks for the suggestions. I think I didn’t explain my problem well.
I need to ensure all update methods aren’t being called with a dt time longer than some threshold.
In order to do that, I’ll have to add the following code to every update method like this:
void update(float dt)
{
if (dt > 1.0f)
{
// dt can be long when receiving email, I prefer my game to slow down than to skip frames
dt = 1.0f;
}
I don’t think there is a way to do exactly that. Common approach to your problem is conceptually
different - if some activity takes too much time to fit between updates, it should be done in its
own thread. Or you can pause the game until it finished.
As I told you Fixed step is the way your updates always will receive the same dt
If you have a big delta between some frames you will update several times your objects
but you set a limitation about how many updates you will do!