Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Sometimes my game runs smooth as butter, other times it stutters terribly.....any ideas?

Discussion in 'Editor & General Support' started by minibeaststudios, Mar 23, 2019.

  1. minibeaststudios

    minibeaststudios

    Joined:
    Aug 9, 2017
    Posts:
    35
    I have been using the various Profiler tools to try and get to the bottom of this, but nothing immediately obvious seems to strike me as the culprit - so I thought I'd ask here in case anybody has any suggestions or insights about what could possibly be causing this issue.

    Basically, I can play my game and find that the experience is completely smooth, no jitter, no stutter, steady frame rate, etc. However, I can then run an identical test* and find the opposite to be true, lots of lag and stuttering going on (not just the camera / player, the game on the whole).

    *i.e. launch the game (standalone, not in the editor) - go through the same menu flow - and play the same level with the same character and game settings

    I'm also currently calling the following in code based on previous recommendations I've read:

    QualitySettings.vSyncCount = 1;
    Application.targetFrameRate = -1;

    But honestly I'm not sure if that's best practice, other than eyeballing the resulting performance.

    Any tips, advice or nudges in the right direction would be greatly appreciated!
     
  2. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    3,015
    Well, first make sure your computer is not to blame. For example, do you have anything running in the background that periodically bogs down your PC? For example, an email client, Dropbox client, etc. Windows anti-malware can often create an IO bottleneck for several seconds.

    Beyond software, monitor your hardware. Use CPUID HWMonitor to look at the temperatures on your CPU cores and your video card. With most Intel CPUs, there will be tiny micropauses anytime the CPU is at least 65 degrees Celsius. There won't be a hard shutdown until much hotter, but the micropauses start around 65 degrees. Video cards have similar thermal throttling functions, but the temp varies on them.

    As for V-sync, I hate V-sync. It makes games stutter sometimes even when the framerate is plenty high. I like to disable V-sync and then limit the target framerate to 150 FPS. Don't leave it completely unlimited, though, because running a high end PC at 300+ FPS will generate a lot of heat which will cause micropauses.
     
  3. minibeaststudios

    minibeaststudios

    Joined:
    Aug 9, 2017
    Posts:
    35
    Thanks for the reply ShilohGames.

    I'm seeing the issue on the PC and console I'm developing for so I'm thinking it's unlikely to be a background application/hardware related
     
  4. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    3,015
    It is still probably worth double checking. Weird thermal throttling can cause micropauses.

    Also, is the stuttering occurring in the Editor, in standalone builds, or both?
     
  5. minibeaststudios

    minibeaststudios

    Joined:
    Aug 9, 2017
    Posts:
    35
    It happens in both but I tend not to profile performance in the editor only the standalone / console build
     
    MartinTilo likes this.
  6. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    You could investigate this by comparing profiler captures from 2 such runs (one smooth, one not) using the newly released Profile Analyzer Package. Maybe if you look at it as a summary of frames and the difference between two such summaries, it becomes clearer.