- Home /
How to Reduce the lag?
When I start my build and run it Im frozen and then my screen bounces around and then it starts going smoothly except for a a jerk forward every 5 or so seconds, Is there a way to fix this?
Answer by Rasp1977 · Aug 23, 2013 at 08:58 AM
That depends on what you are doing in your game.
If you create a simple scene with a plane to walk on and a character controller and nothing else, is it still a problem?
If not, then you need to check your scripts for something that takes a lot of time to run.
As good an answer as you can give to such a broad question
Answer by yoda12 · Dec 05, 2014 at 12:29 AM
Its likely the rendering of game graphics, or a script. It could also be you have a lower end computer. Mine is powerful, but unity limits the Frames Per Second to about 60. First, do you have multiple Update functions in you're scripts? This can cause lag/fps drops. If you also have too many While()s, it can also create lag.
Go into the game window and click "Stats" and a small window should pop up. Now, run the game. If you get about 10 fps, then its likely the games graphics taking up power, or like I said, the Updates. If it freezes, it could be either, but likely the scripts. This has happened to me several times. Try changing function Update()
to LateUpdate()
, and adding yield WaitForSeconds(5);
Around the script (if its JavaScript), and also disabling some scripts.
This may not work, but you can also try this.[Keep in mind, that you shouldn't rely on the below code, always program games to not take up performance] :
Create a js file and insert this:
#pragma strict
function Start () {
Application.targetFrameRate = 300;//Target the frame rate to about 300fps
QualitySettings.vSyncCount = 0;//This is vsync. This just tells unity to sync framerate to monitors refresh rate.
//Turn off vSync for better fps, by turning QualitySettings.vSyncCount to 0
}
Another option if you have a less powerful computer, is to turn graphics down. Edit -> Project settings -> Quality, then click fastest. I think the freezing is a script thing though.
Answer by enriquee3ppvgaming2 · May 31, 2021 at 11:54 AM
I am so sorry for the late answer, but the reason that happens is because realtime global illumination is turned on, realtime gi doesn't really work good with slow computers...
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
I made a better shader how do i fix[add _Shadow Strength]help???>Sorry that im asking for to much 1 Answer
Particle memory overhead 1 Answer
10 AI's vs 10 AI's 2 Answers
One specific area of map insanely laggy? 0 Answers