UE4 Show FPS Counter Tutorial
Showing FPS in a game engine is super important! And unfortunately, sometimes it can be a challenge to figure out how to turn it on! Well in Unreal Engine 4, there are a few different ways to turn on the fps counter, and a few variations at that!
Drop-down
In the upper-right corner of the map view, there should be a drop-down arrow. Click this, to get an option to toggle on the FPS counter.
Once enabled, there will be an FPS counter on the right-hand side of the window.
2. Console Commands
When playing in Unreal, you can execute “console commands”. Basically, Unreal has a ton of functionality built-in for debugging or profiling purposes. To execute these, while playing your game, press the “`” key, that’s the key left of “1” and if you held shift, would be “~”.
A little black bar will appear at the bottom of the window. This allows you to type in all kinds of console commands, the main one that we want is “stat fps”. So type in “stat fps” into this bar and press “Enter”/”Return” key.
This should result in the same behavior as option 1.
A slight variation of this command gives you a little bit different information. If you are actually interested in the millisecond breakdown between drawing, GPU, and game logic, you can type in the command “stat UNIT”. Furthermore, if you want this information, but want it on a graph, you can type in “stat UnitGraph”.
3. Hot-Key
So you can also setup a hotkey to do this, or anything else really, for you! This will let you easily toggle these aspects on and off within the editor whenever you like! To do this, you need to be programming in a blueprint. Wherever you are handling your input, you can drop in a node called “Execute Console Command”. Here you can type in exactly what command you want executed, as shown in examples from above. Now you just need to fire this. If you right-click in the event graph, you can create an “Any Key” event. If you click on this event, in the details panel you can see that you can change “Any Key” to a specific key of your choice. Let’s pick “0” for example. It should look something like this when you’re done.
Then when you are playing, you can simply press the “0” key and toggle all of these settings at once. This is shown in the gif below.
That’s it! There’s a few ways to toggle on an FPS counter of various degrees of information. Unreal makes it pretty straight forward, but there’s still a lot of interest here!
Happy programming!