Search Unity

Timeline Pause works as expected in Editor, works wrong in Runtime

Discussion in 'Timeline' started by sergiusz308, Oct 30, 2019.

  1. sergiusz308

    sergiusz308

    Joined:
    Aug 23, 2016
    Posts:
    235
    Hello there, I have a simple timeline with two clips, one after each other.

    First clip - opens doors (two panels are move aside)
    Second clip - closes doors (two panels moving back together)

    When I preview timeline and hit Pause/Resume animation clip stop and resume as expected.

    Here's animated GIF of what's happening:

    https://imgur.com/eI45g3E

    At first I test it hitting Play on the timeline window in the Editor and it works as expected.
    But then in runtime, when I pause timeline from the code (there's marker around middle of the track which does that) first animation clip is reseted back to frame zero, producing this effect of once opened doors suddenly shut closed.

    This is animator for the animations:

    timeline_problem_1.jpg

    Code:

    upload_2019-10-30_21-14-41.png

    What's happening here - any ideas?

    Thanks,
    S.
     
  2. sergiusz308

    sergiusz308

    Joined:
    Aug 23, 2016
    Posts:
    235
    @julien-b @seant_unity Guys, could you please check it out:

    Two clips put sequentially on the animation track. While in editor, it works fine:

    Begining of animation - doors closed:

    upload_2019-10-31_12-52-42.png

    Animation progresses

    upload_2019-10-31_12-53-8.png

    First clip finishes, timeline is paused, doors stay opened (according to animation):

    upload_2019-10-31_12-53-48.png


    BUT during runtime, when I pause timeline (from the script) here, first clip goes back to first frame and doors are closed:

    (Runtime shot)
    upload_2019-10-31_12-55-9.png

    I tried to offset signal - no difference.
    All clips have looping off

    Would appreciate a hint what's happening here - I really want to use timeline here, don't want to fallback to legacy animations and events.
     

    Attached Files:

  3. ewanuno

    ewanuno

    Joined:
    May 11, 2017
    Posts:
    58
    use activation tracks rather than animation tracks?
    activation tracks just activate and deactivate an object (which could contain an animator set to play on awake)
     
    sergiusz308 likes this.
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    .Pause() will release the timeline from the animator, so what you are seeing is control being reverted back to the animator controller. In editor, the controller doesn't run so it the animation isn't being updated.

    Instead of Pause()/Resume() you can play with the speed of the graph as a workaround.

    this.director.playableGraph.GetRootPlayable(0).SetSpeed(0) == Pause()
    this.director.playableGraph.GetRootPlayable(0).SetSpeed(1) == Resume()

    This will work similar to a 'Hold' on the playableDirector.
     
    sergiusz308 likes this.
  5. sergiusz308

    sergiusz308

    Joined:
    Aug 23, 2016
    Posts:
    235
    Thanks for the hint. Is this a desired behaviour and I am doing something wrong, or it's going to changed in the future?
     
  6. sergiusz308

    sergiusz308

    Joined:
    Aug 23, 2016
    Posts:
    235
    Thanks for the suggestion!
     
  7. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    I'll call it a known issue. It's something we'd like to fix, but it hasn't bubbled up to the top of the pile yet.
     
  8. sergiusz308

    sergiusz308

    Joined:
    Aug 23, 2016
    Posts:
    235
    OK, it works with a workaround, so gotta live with it for the time being :cool: