Search Unity

[SOLVED] Issue with resetting timelines

Discussion in 'Timeline' started by dgiddy, May 13, 2020.

  1. dgiddy

    dgiddy

    Joined:
    May 6, 2020
    Posts:
    5
    Hi!

    I have an array of playable directors representing several different timeline tracks. I am operating them with a very basic state machine to stop, start and play the playable directors based on different events.

    My example scenario is that I have 4 states, each state has a different timeline animation to play and I have a script that simply manages at which index to play.

    State 1 (User enters room = animation of door closing plays), State 2 (User clicks on button = triggers a VFX animation) etc.

    However I am hitting an issue with restarting playable directors, when I want to toggle back to a previous state I call PlayableDirector.Stop() on all the playable directors after that previous state, but none of the animations seem to reset until I go forward in the sequence again, its like it forgets to update until its played again.

    Anyone know why this might be the case? Or how I could manage resetting and activating more effectively?

    Thanks!
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    When you stop a timeline it stops changing the animation altogether and leaves it in whatever pose it was last in. If you want to reset it to the initial state (like the first frame) set the time to 0 and call evaluate() on the playable director.
     
    dgiddy likes this.
  3. dgiddy

    dgiddy

    Joined:
    May 6, 2020
    Posts:
    5
    Thank you very much! You da man.

    .Evaluate() was the exact method I was looking for!
     
    AlexPisarev likes this.
  4. Havokki

    Havokki

    Joined:
    Jun 28, 2015
    Posts:
    118
    Does this require some specific settings? After my timeline has reached the end, I set time to 0 and call Evaluate(), but these do nothing.
     
  5. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Then another timeline or animator controller is likely playing. Animation occurs after Update() script calls, so a LateUpdate() might be what you need.
     
  6. Havokki

    Havokki

    Joined:
    Jun 28, 2015
    Posts:
    118
    Thanks for the reply. Found out just a moment ago that the timeline needs to use Hold-mode. Having it in None stops Evaluate from working, possibly because with this mode the PlayableDirector is in Paused state?

    I tried this with a new empty project, which has only one PlayableDirector, one timeline and one script that waits for the timeline to end and then tries to reset it.
     
  7. alexanderFabula

    alexanderFabula

    Joined:
    Sep 1, 2019
    Posts:
    22
    Hey

    I have a problem with resetting the timeline while having a cinemachine track with a clip.

    I reset all my timelines based on my checkpoint system.
    upload_2022-10-12_14-44-37.png

    I use the solution described above. I use director.Stop(); then director.time = 0f (or duration), then director.Evaluate();

    One of my timelines sets a virtual camera live even though it's not highest priority? If I move the clip on the track away from the beginning, it does not do it. So it seems like a weird bug or maybe my method of using Stop, set time, evaluate is not correct.
     
  8. alexanderFabula

    alexanderFabula

    Joined:
    Sep 1, 2019
    Posts:
    22
    The same happens with the rotation of the character object. None of the timelines are playing but it seems like they are so I cannot rotate the character object and cinemachine gets stuck in a specific virtual camera.