- Home /
Sudden framerate drops?
Hey, when I am playing my game I sometimes get some pretty hard framerate drops, sometimes from a steady 80 - 90 fps to below 20. I don't know why, they appear randomly and never at specific moments (for example sometimes when the player is just walking, other times when the player is shooting or interacting). They don't occur incredibly often but often enough to notice. I am not sure if this is cause of my laptop or another factor within the game. Any ideas why this could be?
Very vague question. You haven't specified what type of game, what is in your scene, how many scripts you have running, how many models with how many polies, how much you have going on in general, or even your laptop's specifications for cpu, ram, gpu, anything. Help me, to help you! XD
If it happens randomly, then maybe it's worth taking a look at your laptop temperatures? And maybe clean cooling fans.
@clunk47 Sure, my game is an Online FPS, I have quite a few scripts on the player that are running at the same time but its hard to tell how many really and the laptop I am using is (unfortunately) a mac book pro. The scene I am using is just a small scene with just a few blocks lying around, simply to test some basic mechanics. @ArkaneX good idea, I am not sure how to do that on mac book but I will try and inform myself.
$$anonymous$$y money's on a garbage collection slowing the game down. There wouldn't happen to be any code that generates new objects every Update (strings, maybe)? Possibly something that looks like the code samples in Understanding Autoatic $$anonymous$$emory $$anonymous$$anagement?
Well every time I have frame drops I check my scripts/Image effects (image effects are pro only or trial). $$anonymous$$ost of the time it is caused by image effects (with pro you can track them down with the profiler). I often am to ambiguous when setting up image effects causing them do bottleneck my frame rate by using to much resources for high quality and stuff.
Check anything else that might be performance heavy and tweak it down, optimizing a game can take some time.
Answer by Borzi · Oct 11, 2013 at 03:57 PM
Okay so I am not 100% sure on a perfect answer, but I noticed a lot of the lag was reduced after some tweaking, especially when I am not running the game in Unity but when actually running the build, the framerate is pretty steady. Here are the two factors that I think effected it the most:
Add some fan cooling to my Laptop
Use less static scripts and replace them with "GetComponent" as its faster and requires less CPU
If you have anything else that might help be sure to comment it, I hope this can help some other people who are experiencing similar issues.
Unity has a built in profiler you can use to see what those performance spikes are : https://docs.unity3d.com/$$anonymous$$anual/Profiler.html
I would also recommend caching any GetComponent calls in your Start() function, as calling those repeatedly is unnecessary overhead. Additionally, be careful what you put into Update(), and consider using co-routines ins$$anonymous$$d if your logic doesn't need to be called every frame. But first, check out the profiler to see where your spikes are co$$anonymous$$g from.
Answer by Vetpetmon · Nov 30, 2014 at 07:26 AM
I totally know the answer to your problem. Frame rate depends on these occasions:
To many objects or you have used terrain
Graphics quality is too high
you did not set the expected frame rate code:
function Awake () {
// Make the game run as fast as possible in Windows
Application.targetFrameRate = 300;
}
note: you can set the frame rate to any number if you want.
networking being used
computer is hot and needs cooling ASAP
need bigger RAM
Or, you computer is just slow
These answers are %100 tested and works. This may help you get the speed of the game you want it to go. Or it might just kill you computer(Overwork it).
Answer by DavidVella · Jun 30, 2017 at 08:43 PM
I had frame rate drop when coding for a mobile device. My solution was to modify The Camera Rendering Path to Legacy Vertex Lit which made a whole 30fps difference.
Cant believe no one has mentioned this. Improved my FPS by 10 in just one setting! Thanks!
Answer by hendryshaikh2004 · Mar 09, 2021 at 11:57 AM
Man I have The Same Problem but nothing seems to help, My Game runs smoothly but then suddenly it goes to 0 fps. Can Anyone help?
Your answer
Follow this Question
Related Questions
My Character lags when moving, when i have a custom made blender model what should i do? 0 Answers
3d model with lower poly count than another model causing tons of lag 0 Answers
Android running at 30 FPS 1 Answer
Animation are not fluid in android 1 Answer
Android game LAGS on PORTRAIT but it doesn't lag on LANDSCAPE 1 Answer