Framerate limiting

I have some aspects of the game that are on-contact damage dealers, and so I want them to do a specific amount of damage per frame, but this goes up with higher FPS.

It is a good idea to limit fps to get around this?

Edit: I tried playing around with a frame rate limited, setting it at 60fps, but even then it only tops out at 48 fps. When I set it to 70, it hovers around 70, but at 60fps, it’s around 48.

Work out how much damage should be inflicted per second, and use that figure times TimeDelta(). It’ll ensure that the damage amount will be dealt every second.

So if the damage is 5, then it’s 5 * TimeDelta() that you take off.

Thanks for the reply.

When I do that, it actually does more damage on the lower framerate, it’s actually like the exact inverse of the damage ratio that I was getting on just straight on contact damage without using TimeDelta().

Something to keep in mind is that anything in Chromium is refresh rate limited (forced Vsync). GDevelop games are built using Electron, which is Chromium based.

So if you have a 144 hz monitor, or are running at 75 hz or something similar, you won’t be able to hit 60 fps as it isn’t a clean divisor of your refresh rate. This means it’ll likely drop to half the framerate, or a rate that is divisble (48 fps can go into 144hz, for instance).

As far as Timedelta:
Timedelta is framerate independent as it works off time between frames. E.g. on a 60 fps game, 1 frame is roughly 16ms, or 0.016 seconds (what Timedelta() would return). In a 30 fps game, 1 frame is ~33ms, or roughly 0.033ms.

With 5*timedelta if you're running at 60fps, in a full second you would get (5*~0.016)*60, or 5. 
With 5*timedelta if you're running at 30fps, in a full second you would get (5*~0.033)*30, or 5.

Both end up with the same result over time. So you’re technically going based off time past rather than framerate at all.

1 Like

With 5timedelta if you’re running at 60fps, in a full second you would get (5~0.016)60, or 5.
With 5
timedelta if you’re running at 30fps, in a full second you would get (5*~0.033)*30, or 5.

I’ll look at this in the morning, but just doing the math I’m guessing I could just change the “5” to a number that includes and calculates / draws from the current fps, to over or undercompensate for differences in frame rate?

Thanks again.

If that’s the case, you’ve implemented it incorrectly.

Are you using 0.5 * TimeDelta()? Note that in my post, I used the example of a damage of 5, not 0.5

Yes haha, for some reason it’s still inconsistent. It’s a moving projectile that was ideally doing 20 points of damage per framerate tick.

Prior to using timedelta, it was more or less getting one extra tick in per shot. So the damage was higher on higher framerates, at a ratio of like 14:11. (The ratio is based on how many hits it takes to kill the enemy, tested many times).

I tried using this to get it to be more consistent so it hit for roughly the same amount of damage (i.e., 20 damage per tick).


But then for some reason it’s the inverse effect; it does more damage on low framerates, at a ratio of 11:14 more or less.

I guess I can just limit the max framerates, but for some reason it never reaches 60 even on high performance, and just stays at 48.

How are you deducting the damage? Can you screen snip the events around it?

Actually I found a workaround using TimeDelta() and some math. So TimeDelta is indeed the way to go for relative consistency across framerates. THANKS again!!!

creating a game design that’s dependent to fps is always a bad idea, you want a consistent result regardless of the fps. it’s much better to depend on the amount of time per damage instead of frames per damage.

Oh yeah, now I realize this and second time around I’m not doing anything like that again.