Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

Is the order of track execution uncertain?

Discussion in 'Timeline' started by zhuxianzhi, Feb 5, 2021.

  1. zhuxianzhi

    zhuxianzhi

    Joined:
    Mar 30, 2015
    Posts:
    85
    I have 2 Tracks, the first Tranck activates the object in the first frame, and the second Tranck plays the animation of the object in the first frame.

    In the preview mode and editor environment, everything is normal, but under Android or IOS, there is a certain probability that the animation will not play.

    My guess is that the playback animation track was executed first, and then the activation object track was executed, which caused the problem.

    Is the order of track execution the same as the order of the TimeLine window?
     
  2. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    474
    Execution order is a bit more complicated than "tracks execute in order".

    Animation tracks execute after all the other tracks, buy they should mostly run in the order the are laid out in the Timeline, unless there are other animations playing on the same animator. In that case, they will play in an arbitrary order (but still after scripts) in order to coordinate with the other animation sources.
    Script-based tracks (activation and most custom tracks) should run in the same order as they are laid out in the Timeline. This does not necessarily guarantee the everything has executed, though. For example, the cinemachine track executes in order, but cinemachine itself has some execution that happens in LateUpdate, so you cannot have a track that reads the result of cinemachine and does something with it.


    Now.. to answer for your specific situation:

    The animation track should always run after the activation track. But, the fact that this happens only on iOS and Android points to a probable performance issue.

    It might be a frame drop that makes us skip some crucial frames, or something could have not loaded in time.

    Timeline doesn't guarantee that every frame is executed, which means that if your activation goes from on, to off, and back to on in a few frames, it's possible that it may never be on if the framerate is pretty bad.

    Have you tried in a Windows/Mac build?

    If it happens also on desktop platforms, then it may point to a discrepancy between editor and standalone, otherwise my best guess is a frame drop issue.

    If you can make a small-ish reproduction project, you can also file a bug and we'll try to debug your exact issue.
     
  3. zhuxianzhi

    zhuxianzhi

    Joined:
    Mar 30, 2015
    Posts:
    85
    Thanks for the reply, it is indeed the frame loss caused by the performance problem. I use a better mobile phone or set the frame rate to 60, but it basically does not appear.

    Should the frame rate setting of Timeline be consistent with the target frame rate of the game? The default frame rate of Timeline is 60, but the game frame rate is 30.
     
  4. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    474
    Timeline's framerate settings only affect the snapping of clips for edition, it doesn't have an impact on the playback.

    Timeline will play synchronized with the actual game frame time, which is not stable.

    If you want to avoid this kind of problem, you should avoid high frequency activation/deactivation of full game objects and instead focus on enabling/disabling visibility.

    You can also use notifications for logic things that must happen regardless of timing.
     
unityunity