Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[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,440
    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!
     
  4. Yozaro

    Yozaro

    Joined:
    Jun 28, 2015
    Posts:
    70
    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,440
    Then another timeline or animator controller is likely playing. Animation occurs after Update() script calls, so a LateUpdate() might be what you need.
     
  6. Yozaro

    Yozaro

    Joined:
    Jun 28, 2015
    Posts:
    70
    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.
     
unityunity