Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

VSync, Frame Rate, and Refresh Rate

Discussion in 'Editor & General Support' started by Daybreaker32, Sep 8, 2015.

  1. Daybreaker32

    Daybreaker32

    Joined:
    Jun 11, 2014
    Posts:
    73
    I've built a 60fps PC game which run fine on my PC with 60hz refresh rate monitor with QualitySettings.vSyncCount = 1

    I tested it on my friend PC and found some aspects of the game speed up (most notable one is animation).
    Apparently, he use a 120hz refresh rate monitor and after some research I've fixed the game by set the QualitySettings.vSyncCount = 2 from here.

    My questions are:
    1. If I set the game to 120fps is the game will be run alright on his PC?
    2. If I set the game's preferedRefreshRate to 60 is the game will be run alright on his PC?
    3. Is there any relation between those three (VSync, fps, and refresh rate)?
    4. What about other uncommon refresh rate monitors (50hz, 90hz)?
    I couldn't experiment or check it myself because I don't have any 120hz or monitor with other refresh rate.

    Thanks.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,400
    You should program your game to be framerate-independent. "Fixing" it by setting vsync count to 2 isn't a fix; there are varying refresh rates as you note. This means using Time.deltaTime appropriately and so on. If anything ever runs at a different rate due to framerate variations, that means you need to fix your code.

    --Eric
     
    Joe-Censored likes this.
  3. Daybreaker32

    Daybreaker32

    Joined:
    Jun 11, 2014
    Posts:
    73
    Thank you Eric for your answer, but could you elaborate please?
    All of my logic are framerate-independent (coroutine, loop, etc).

    Is unity animation framerate dependent?
    If I set Application.targetFrameRate = 60 or 30 or 120, the animations (and all aspect of my game) still good but why it broke on 120hz monitor?
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,400
    Of course; it's based on time, not frames. There's nothing special about a 120Hz monitor in particular that would "break" anything, it just means something in your game is not framerate-independent, but since I didn't write it and know nothing about it, I can't tell you more.

    --Eric
     
    Joe-Censored likes this.
  5. Daybreaker32

    Daybreaker32

    Joined:
    Jun 11, 2014
    Posts:
    73
    Hmm, is there any other reason beside framerate-dependent code?
     
  6. Daybreaker32

    Daybreaker32

    Joined:
    Jun 11, 2014
    Posts:
    73
    60hz monitor


    120hz monitor


    I'm really sure that all of the logic related to the animation (and other mechanics) are framerate-independent.
     
  7. Shawn-Halwes

    Shawn-Halwes

    Joined:
    Jul 17, 2013
    Posts:
    51
    @daybreaker93 I know this is really old, but just wondering how if you resolved this?
     
    Zimbres likes this.