Search Unity

Feedback Time.currentDeltaTime

Discussion in 'Scripting' started by koirat, Mar 12, 2021.

  1. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074
    Should we have Time.currentDeltaTime

    Would return Time.deltaTime or Time.fixedDeltaTime depending if we are running it in physics loop or renderer loop.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    This is how Time.deltaTime already works.
     
  3. Lekret

    Lekret

    Joined:
    Sep 10, 2020
    Posts:
    358
    Yes, during the time where all FixedUpdate methods are called, Time.deltaTime will already return Time.fixedDeltaTime.
     
    Joe-Censored likes this.
  4. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074
    No s**t was I so wrong for so many years ?
    Was it like this from the beginning ?

    How can I obtain Update() kind of deltaTime in FixedUpdate ?
     
  5. Lekret

    Lekret

    Joined:
    Sep 10, 2020
    Posts:
    358
    I guess this was like that from the beginning, otherwise it would be quite big change which big companies can't afford, because of compatibility and legacy code.

    You can simply save Time.deltaTime into a field in Update. But I can't expect the case when it's even useful.
     
    PraetorBlue likes this.
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    At minimum it has been this way for a very long time. The farthest back the official docs go seems to be 3.5.1, and it worked the same in that version.

    https://docs.unity3d.com/351/Documentation/ScriptReference/Time-fixedDeltaTime.html