Follow

Target frame rate or V Blank not set properly

Symptoms

  • Unity is ignoring Application.targetFrameRate
  • The application is capped at higher or lower than target frame rate
  • VSync is not capping to 60/30 fps

Cause

Unity intentionally ignores Application.targetFrameRate when V Sync Count is active. V Sync Count is a property in the Quality Settings (Edit > Project Settings > Quality).

VSyncCount.png

VSync syncs the games frame rate to the refresh rate of the monitor (traditionally 60hz), meaning you are capped at that fps (frames per second) independent of target frame rate. On modern hardware, including some mobile devices, you can have displays with refresh rates of 120hz or 144hz. On these devices, when VSync Count is set to Every V blank, they are capped at 120 fps and 144 fps respectively.

When VSync Count is set to Every Second V Blank it is capped at half the refresh rate (for example, 60hz is capped at 30 fps).

Resolution

If you want to use targetFrameRate to have finer control over the frame rate, set VSync Count to Don’t Sync. You can change this at run time using the API calls Application.targetFrameRate and QualitySettings.vSyncCount.

You might use these API calls when you only want your application to run at a higher frame rate during intense movement scenes, but cap your frame rate during menus.

The code to do this is as follows:

To set the target frame rate to 30 fps:

Application.targetFrameRate = 30;
QualitySettings.vSyncCount = 0;

To set it to Every V Blank:

QualitySettings.vSyncCount = 1;
Application.targetFrameRate = 60; // This will update the current setting, but be ignored due to vSyncCount being greater than 0.

 

More Information

https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html 
https://docs.unity3d.com/ScriptReference/QualitySettings-vSyncCount.html 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.