How do game developers make games run at a certain speed when they have to run on different hardware?

228 views

I’m guessing modern frameworks have this built-in so developers don’t really have to worry so much, but how is it achieved? For example, if I want a character to move at a certain pace no matter what hardware is running, or how much is happening on the screen at the time, how does the code control that?

In: 2

4 Answers

Anonymous 0 Comments

Unity enthusiast here.

This particular engine has something called deltaTime. This is a time that elapsed from last frame. Since video game is just a loop with one iteration every frame, multiplying some values by deltaTime makes them framerate-indepemdent.

If I write a code like: if W button is pressed, move 1cm forward, then this gives me speed of 30cm/second if game is running at 30FPS or 60cm/sec if it is 60FPS. Number of FPS = Number of cm per sec.

But I can also do: if W button is pressed, move (50 * deltaTime) cm forward. This will result in a constant movement at 50 cm/second, regardless of framerate.

Not every dev thinks about it, unfortunetely. E.g. Fallout 76 was purposely locked by devs at 30FPS. Movement was framerate-dependent, so when players modded the game and unlocked higher FPS values, they were zooming around the map few times faster.

You are viewing 1 out of 4 answers, click here to view all answers.