- Home /
Why fps loss when I press keys?
I'm confused about this question in my project.
So I try to find the reason......
In the end.
I create a new project to test.
And the FPS loss still exists.
This is a very simple environment.
I just press the key "F" and the FPS is lost from 180FPS to 130 FPS.

Anyone can tell me why?
And this is can solve?
Or maybe we can ignore this?
My version is unity 2019.4.4f1.
And here is the project :
https://drive.google.com/file/d/1RtxIH_83ncPb5FHdST9atODsMuhMJ0OW/view?usp=sharing
I watched :
https://answers.unity.com/questions/186343/why-does-holding-down-any-button-cause-20-30-fps-l.html
But the problem is not because OnGUI()
I try to print the log to test the FPS still lose.
About FPS code:
void ExtraFPS()
{
deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
float fps = 1.0f / deltaTime;
displayFPS = fps;
//fpsText.text = Mathf.Ceil(fps).ToString();
}
void OnGUI()
{
if (isShowFps)
{
GUI.Label(new Rect(Screen.width - 200, 25, 400, 200), $"<color=green><size=40>FPS:{ displayFPS }</size></color> ");
}
}
Answer by Rechronicle · Oct 18, 2021 at 07:41 AM
Personally, I think you can ignore it unless it goes down to below 30 or if you are experiencing stutter/lagging in input.
Thanks for the reply.
Because I developing the type of game that is bullet hell type.
So I hope there has enough "space" for bullets.
In my project now in editor.
The boss level is 85~95FPS.
When press key FPS will lose to 7X.
I agree fps 7X is don't worry.
But... just uncomfortable. lol.
And worry if someday for the future that I need to face this FPS issue.
P.S. I have not yet to test the export version. Hoping the situation is just in the editor.
A quick note that playing in the editor will be somewhat slower than in exported version. I always test my game in export mode to see if it performs smoothly.
If you worry about performance, looking at Object Pooling might be useful for the bullet hells. And good luck with your game dev! :)
Your answer
Follow this Question
Related Questions
Fps Aiming Script help 2 Answers
Turning the game into an FPS 1 Answer
Network fps swap cameras 1 Answer
Js modding support 0 Answers