Search Unity

Force constant framerate for reording purpose.

Discussion in 'General Discussion' started by koirat, Jan 25, 2021.

  1. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    So how can I force unity to do Update and fixed update with constant deterministic deltaTime and fixedDeltaTime.

    I'm ok with slowdowns I need it for game-play recording, I need to be able to specify this frame-rate.
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,569
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Unity can't be forced to run these at an exact time. Unity makes a best effort to run FixedUpdate at the right time, but since it runs on the same thread as much of the rest of the engine it cannot guarantee to run at the exact time it is expected to. FixedUpdate does not interrupt other code running on the same thread, and if that other code takes too long then FixedUpdate will be called late.

    If you need something to have exact timings, I'd suggest doing it on your own thread.
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    angrypenguin and Joe-Censored like this.
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,678
    It doesn't matter when FixedUpdate actually runs because it fakes "Time.fixedTime" and "Time.fixedDeltaTime" to appear that it was called at the right time. Of course, if you depend on the wall clock, you're not going to have a good time.
     
    angrypenguin, Kiwasi and Joe-Censored like this.