Search Unity

Unscaled Time animation not working on game launch

Discussion in 'Animation' started by AlternativeShit, Mar 29, 2021.

  1. AlternativeShit

    AlternativeShit

    Joined:
    Feb 17, 2021
    Posts:
    18
    I have an animation running as soon as the game launches, with my Update Mode parameter set on "unscaled time", because my timeScale is equal to zero the very first seconds of the game (for a number of reason that are not relevant here).

    However my animation runs as if it was on "normal" and not on "unscaled time", making it very laggy. And I have no idea why.

    Here are the things I try :
    - If I make my animation last more than 1 second, it works how it is supposed to work. But if i make it last less than 1 second, it just doesn't run smoothly at all.
    - Of course, if I change my timeScale to 1, it doesn't work either, since I'm on "Unscaled Time".
    - And of course, if I change my Update Mode to "Normal", it doesn't work either, since my timeScale is 0.

    Any idea how this could be happening?
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    Not usually a fan of necroposting, but this was driving me crazy too.

    I am pretty sure it's the same stupid design decision where
    Time.unscaledDeltaTime
    can be a ridiculously huge number on the first frame of the game play (unlike
    Time.deltaTime
    ), but then it suddenly calms down and is a normal amount of time. Unity says it's "by design" or "not a bug" that this happens.

    Make an enabled UnscaledTime Animator with an animation in the first state. Play the scene by single-stepping. Works flawlessly. Play the scene without single-stepping. Doesn't play all the way through or doesn't get the transition time right.

    Workaround: Set the Animator to be disabled on start. Coroutine to wait a couple frames, then enable. Boom, works fine whether single-stepped or not.

    I tried a bunch of other workarounds, like adding another state at the beginning of the Animator state chain, waiting for a transition trigger, etc., but I never got a working recipe until I just said eff it and disabled the Animator until the scene was established a frame or two later.