Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Feedback [Bug] Timeline Play On Awake does not work properly

Discussion in 'Timeline' started by larex39, Oct 31, 2019.

  1. larex39

    larex39

    Joined:
    May 1, 2014
    Posts:
    82
    In SceneA I have animation in timeline with a play on awake turned on, which moves my gameobjectX out of the screen and slowly brings it back. (Initial position of gameobjectX is in the middle of the screen)

    But When I am in SceneB and I load SceneA, there is one frame glitch, where I see my object for a fraction of second in the middle of the screen.

    I debugged the position of the object and the timeline moves it on a second frame but not in the expected Awake method.

    Why is that?
     
  2. larex39

    larex39

    Joined:
    May 1, 2014
    Posts:
    82
    This is also very bad when I set up an activation clip starting in the middle of the timeline(That means at the first half of the timeline the object is deactivated), but when I run a timeline with turn on awake on. My Gameobject on the first frame is still activated (so all the onStart, Awake, onEnable methods are triggered ), and only after that inside the second frame it turns of. But I want this game object to be inactive from beginning exactly how I am defining it in the timeline. So the timeline should take care of it, that's how I am expecting it to work
     
  3. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,035
    If I recall correctly, PlayOnAwake starts the timeline playing on the next frame because the delta time between the first and second frames can be very long - due to loading, instantiating and other resource work done in Awake(), but some timer modes will cap the delta time to 1/30.

    That caused timelines to appear to not start at the beginning, or, if the delta time is capped, for the audio to be wildly out of sync.

    In your case, start with the object disabled in the scene. The activation track can be set to enable it on completion (instead of using revert).
     
  4. larex39

    larex39

    Joined:
    May 1, 2014
    Posts:
    82
    Well, that what I wanted not to do because I am losing track of what I have in my scene if I disable everything.
    But why it can't be fixed? inside Timelines awake method you can just check all the clips starting values, and just set them how they are, It doesn't need to be played right away just set and it will work. It is super bad if I am expecting Timelines start on awake to not start when awake method is trigerred.
    It should be called start next frame.
     
  5. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,035
    I did forget to mention that timeline (playables) processes between Update() and LateUpdate(), so Awake, Start, OnEnable will be called for anything enabled in the scene .

    I'm not sure that the behaviour is broken, actually. If the scene default of a gameObject is 'on', then Awake is expected to be called when the scene loads. Timeline should not break that contract.

    But you can probably get the behaviour you want with a script that calls playableDirector.Evaluate() in an Awake() method. That will force evaluate the first frame of the timeline.
     
    larex39 likes this.
  6. larex39

    larex39

    Joined:
    May 1, 2014
    Posts:
    82
    Amazing that actually works! Thanks a lot.


    I don't think Timeline is breaking the contact, it is basically overriding the behavior because if I am setting the play on awake and I am expecting that everything setup on the timeline will be triggered inside awake method.
    So I think playableDirector.Evaluate() should be inside Timelines awake method by default if I press play on awake.