- Home /
What is the correct way to create FPS counter?
Hi, I'm having a trouble creating FPS counter and I wonder why.
I run this code float fps = 1f/Time.deltaTime
in Update(), but the output varies a lot from editor's stat window (like fps=120, stats=190).
So, unless it's the editor that's broken, that doesn't work, why? (Also, I would like it work with builds, not just editor)
Answer by Bunny83 · Jul 12, 2019 at 08:46 PM
Your calculation is perfectly fine and does give you the correct framerate as long as the framerate is higher than 3 fps (because unity caps deltaTime at 0.3333).
The stats window does not report the actual framerate but concentrate on the graphics performance. So it's more a summary of the rendering load without any other editor. Have a look at this:
The amount of time taken to process and render one game frame (and its reciprocal, frames per second). Note that this number only includes the time taken to do the frame update and render the game view; it does not include the time taken in the editor to draw the scene view, inspector and other editor-only processing.
If you actually use a overlay like fraps which can display an fps counter inside your game window, you will notice that it matches 1/deltaTime
Your answer
![](https://koobas.hobune.stream/wayback/20220612204808im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Low FPS rate. Can't find the problem. Followed Unity's Guide 2 Answers
Increasing Unity Frame Rate? 0 Answers
is this framerate script okay? 2 Answers
Game seems to be locked to 30FPS 1 Answer