Here’s a super simple tutorial on how to make a basic FPS counter #shorts
Get my Complete Courses!
Learn to make awesome games step-by-step from start to finish.
Get my Steam Games
RELATED VIDEOS
Quick Unity Tutorials
The easiest way to make an FPS counter is to simply do some math using Time.deltaTime
It has the number of seconds elapsed since the last frame so with 1f / Time.deltaTime you get an instant FPS counter.
To make it more smooth, just store multiple deltaTimes in a List and average them out.
Get Code Monkey on Steam!
Interactive Tutorials, Complete Games and More!
If you have any questions post them in the comments and I’ll do my best to answer them.
Subscribe for more Unity Tutorials
See you next time!
Support on Patreon
Grab the Game Bundle at
Get the Code Monkey Utilities at
#unitytutorial #unity3d #gamedev
——————————————————————–
Hello and Welcome!
I’m your Code Monkey and here you will learn everything about Game Development in Unity using C#.
I’ve been developing games for several years with 8 published games on Steam and now I’m sharing my knowledge to help you on your own game development journey.
I do Unity Tutorials on just about every topic, Unity Tutorials for Beginners and Unity Tutorials for Advanced users.
You can see my games at www.endlessloopstudios.com
——————————————————————–
– Other great Unity channels:
Unity –
Brackeys –
Dani –
Jabrils –
BlackthornProd –
Sykoo –
Jason Weimann –
Jonas Tyroller –
——————————————————————–
– Website:
– Twitter:
– Steam:
Like some people have mentioned in the comments, you should use Time.unscaledDeltaTime instead of Time.deltaTime since that one will not be affected by Time.timeScale;
All the logic is the same, just swap that one
I get quite a difference between the framerate output of my own FPS counter and the framerate showing in the stats window of the Unity editor. Why is that?
Simple and great, thanks!
Thanks a lot!
The last time i used a circular buffer was in university. Nice to use it again.
Problem if FPS is 1, then it shows 50 FPS.
private float deltaTime = 0.0f;
private void Update()
{
deltaTime += (Time.unscaledDeltaTime – deltaTime) * 0.1f;
float fps = 1.0f / deltaTime;
}
little optimization, the CalculateFPS function can be shortened to frameDeltaTimeArray.Length / frameDeltaTimeArray.Sum()
The displayed FPS is almost always double what Unity displays in the editor stats panel. Any advice?
Awesome!
Time.smoothDeltaTime
tankssssss
I belieive this only work in Unity Editor and not a built version right?
int fps;
void Start()
{
startCoroutine(Reset());
}
void Update()
{
fps += 1;
}
IENumerator Reset()
{
yield return new WaitForSecondRealtime(1);
fps = 0;
startCoroutine (Reset());
}
How do i make it slower? :O
its like that meme when you look a away for a second in a math class


How's it going can you make a full video on making slot machine game with unity, from animations, effects to reels, and logic? similar to these type of vids but with detail https://www.youtube.com/watch?v=UHzjlxMaoEE https://www.youtube.com/watch?v=Pz4D5u4CpOk , keep up the great work, also do you collaborate on projects?
I finally used:
fps += 1; in update and a coroutine each second setting fps to 0.
thanks a lot dude
This is awesome. Perfect for a multiplayer game.
I added if (((lastFrameIndex + 1) % 10) == 0) before setting the text so it was only changing the number every 10 or so frames, flickering a little less. You could adjust that 10 and get different rates, as long as it's evenly divisible into 50.