We all know and hate the FPS lock that some games have introduced over the past few years. And while most of you have criticized the devs using it, did you ever understand the reasons behind that decision? Well, time to get some insight information as Reddit’s member ‘Pyronar‘ explained why this phenomenon has been happening.
While Pyronar is not working at any video-game company, he does have an experience with games engines as he’s currently building one from scratch. As he pointed out, this is done in order to get knowledge of the little details and not in order to see if he can come close to what triple-A engines – Unreal Engine 4, CRYENGINE, Unity, etc – can achieve.
Pyronar claimed that three actions – in short – define how games engines work. Video-game engines get and process input, update game state and then render the frame. This is the main loop of a game, and if developers write code following those three steps they will get a game that runs at different speeds depending on how high their FPS goes. As a result of that, there are three solutions via which developers can overcome this issue.
These three solutions are: FPS lock, Delta Time and Double Loop.
The first solution is the one most of us have been witnessing in all those awful console ports. This is described as the easiest and probably the worst solution since developers can lock their FPS and make everything run at the same speed.
The second solution provides an unlocked framerate, however it introduces various issues. Via this solution, developers can leave the framerate unlocked and measure how much time passed since the last frame and operate based on that.
The third solution is the approach that most modern engines take. Basically it comes down to making two loops. One of them runs every X milliseconds, and the other one runs every frame. The first one updates the logic while the second one renders your game.
As you’d expect, Pyronar also provided some arguments to those ridiculous claims we’ve heard in the past such as “X engine cannot unlock the FPS”, “there are artistic reasons to locking a game at 30 FPS” and “it is super difficult and costly to unlock the FPS”.
As Pyronar noted:
1) Optimization is very difficult and some devs just don’t have the time and resources to make sure their game maintains a stable 60 FPS.
As with many statements on this list, this one is technically true, but has nothing to do with FPS locking. If my PC can’t run your game at higher than 30, that’s an optimization problem. If your game is locked at 30, that’s a design problem. There is no reason not to provide the end user at least an option to unlock framerate or set a higher cap if your only concern is optimization.
2) Because of certain early design decisions sometimes 60 FPS is not achievable.
Technically true. Only here in software engineering we don’t call those things just “design decisions”, we call them design mistakes. Basically when people say this they are referring to everything I’ve described above.
3) Not all engines have the capabilities to unlock FPS.
First of all, an engine is not a sealed box, at least most of them aren’t. If you need some piece of functionality, write it. It can be difficult to do, but still not as difficult as doing it from scratch. Secondly, if there is absolutely no way you can incorporate unlocked framerate into an engine, why are you using that engine to begin with? Thirdly, most modern engines have tools for this. The most famous one is Unity; it basically has the double loop set up already (functions Update and FixedUpdate).
4) There are artistic reasons to locking a game at 30 FPS.
Okay, I’m not going to argue that there aren’t any reasons for that. I’m not much of an art person. However, there is one thing that I know for sure. If your game is designed in a proper way, providing an option to unlock framerate or at least switch to a 60 FPS lock should be trivial. Even if you expect your game to only run at 30 FPS, the lock is still a bad idea.
5) All of this is super difficult and costly.
It’s not that costly, but it’s difficult. Which is why game engines like Unity implemented it for you ages ago.
So now you know why some games are locked at 30fps, and why modders can sometimes unlock the FPS without major issues (or with some funny side-effects).