Search code examples
c#iosperformanceunity-game-enginevsync

How to set target frame rate with Application.targetFrameRate to fix bad frame rate (vsync)


enter image description hereAfter noticing my game was quite jittery when building it to my iOS device I checked the profiler and found out that vsync was responsible. After a little of research I figured in order to resolve the jitteriness of my game I had to set the target frame rate to 60 as its value was set to 30 by default.

So in one of my scripts in attached to a gameObject in my gameplay scene I I included the code:

void Awake(){
        Application.targetFrameRate = 60;
}

After building my app again I am not sure if this made a difference so I am posting this question to ask how to set the target frame rate correctly as my way seems to not be working...(maybe use qualitysettings.vsynccount although I am not sure if that is meant for iOS)


Solution

  • You don't need to worry about VSync "using" a lot of CPU in the profiler. I remember I was confused by this. VSync is not causing the performance issues you're having.

    You can look at this link for a good explanation: http://answers.unity3d.com/questions/994225/vsync-decreases-performances.html

    Also if for some reason you still want to disable VSync, you can do this by going to

    Edit > ProjectSettings > Quality

    and setting VSyncCount to Dont Sync

    If you want to do this using code, I think the following statement also works:

    QualitySettings.vSyncCount = 1;