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

Is Update frames tied to gameplay FPS?

Discussion in 'Editor & General Support' started by Valderhaug, Sep 6, 2015.

  1. Valderhaug

    Valderhaug

    Joined:
    Jun 24, 2015
    Posts:
    4
    I do not want to lock my games' FPS. There's the horror stories of games where if you increase FPS above the 'limit' you speed certain things up and/or screw over the physics.

    Is there anything else that I should be aware of in regards to preventing this?
     
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,384
  3. Cheerio

    Cheerio

    Joined:
    Aug 3, 2013
    Posts:
    19
    To unlock your framerate, make sure you set "Application.targetFrameRate" to -1. Once you do, make sure that whenever you have an update function, you take into account how much time has passed using "Time.deltaTime". So if you were moving an object you would do something like: "transform.position = transform.position + dir * speed * Time.deltaTime".

    The reason games typically have locked fps is because it can be hard to have complex simulations work with drastically different update times. Unity's physics is an example of this and the way they solve it is that Physics updates at fixed time intervals. If you have something that updates and interacts with physics, you can use the "FixedUpdate" function however this function may run many times a frame or no times at all based on how much time has gone by.