Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Current animation frame is not "hold" when Timeline is paused

Discussion in 'Timeline' started by Kiupe, Sep 7, 2017.

  1. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Hi guys,

    I want to play a Timeline, then pause it at a specific moment, wait for a specific event in my game and then resume the Timeline. The problem is that when I pause a Timeline it does not "hold" the current frame but reset everything. Is that normal ? I hope not !

    Thanks
     
    Last edited: Sep 8, 2017
  2. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    I forgot to specify that when I resume the Timeline it actually resumes correctly. So pausing is kind of like a stop but keeping in memory the last played framed so resuming works. But it's not a real pause because it does not "freeze" the timeline to the current frame.

    Do you experience the same ?

    Thanks
     
  3. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    Still digging on that issue. It seems that animation tracks/animation clips are in cause here. When pausing it seems that the currention animation clip playing has no effect - like it is the one that can't hold the current state. Any idea how I can fix that ?

    Thanks
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Pausing the graph through the PlayableDirector keeps the graph in memory, but it no longer evaluates. It sounds like you want it to stop advancing time, but still evaluate each frame (e.g. like 'Hold' wrap mode does).

    We should add an option on the Pause to indicate which behaviour you want. There is a workaround you can do to get the Hold behaviour.

    You can try
    playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0);

    That will effective do the same thing as a hold. You will not get any callbacks in custom scripts, but the delta time should be 0.
     
    dithyrambs likes this.
  5. Kiupe

    Kiupe

    Joined:
    Feb 1, 2013
    Posts:
    528
    I think "Pause" is a word that let you think that actually the "timeline" will"pause/hold" the current frame. To add an option to do that would be useful.

    Thanks !
     
    Last edited: Sep 8, 2017
  6. cyraxchel

    cyraxchel

    Joined:
    Jul 10, 2012
    Posts:
    3
    I set "Apply Root Motion" on Animator component on my animated object. And then "pause" in timeline start work properly. Animation not reset on pause.
    On object, that contain Playable Director, this parameter enabled by default. And this confused me, because I have two animation track, and one nornaly paused and second reset animation on pause.
     
    Heartwood_jw likes this.
  7. Kalkatos

    Kalkatos

    Joined:
    Jul 18, 2013
    Posts:
    1
    I got into this issue.
    As @Kiupe mentioned, the intended behaviour that anyone would expect from the word "Pause" in a Timeline would be to freeze/hold the current frame, not deactivating/resetting the entire timeline over.
    I believe that should be the default for PlayableDirector.Pause().
     
  8. yutoVR

    yutoVR

    Joined:
    Jan 10, 2016
    Posts:
    2
    PlayableDirector.Pause() will also call OnControlTimeStop in ITimeControl.
    The workaround never call it so I was able to achieve my goal.

    Thank you!
     
  9. visca_c

    visca_c

    Joined:
    Apr 7, 2014
    Posts:
    27
    playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0) will freeze the frame, but i can't animate the object during this freeze.
    Say I have a sequence, where a cut-scene plays using timeline, then a dialogue box pop up, timeline now should freeze. player will click to continue to advance the dialogues, and new dialogue box will trigger emote-like animation on the object, when the dialogue finishes, resume timeline to finish up the reset of the cut-scene animations. But now the problem is, if i use timeline PlayableDirector.Pause(), the animations stop completely, doesn't freeze the last frame as intended. But if i use playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0), during the freeze I cannot trigger animation via code-call. Any solution to this?
     
  10. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    timmehhhhhhh likes this.
  11. AlterVorrin

    AlterVorrin

    Joined:
    Oct 11, 2017
    Posts:
    4
    Hi @seant_unity ! Thanks for the suggestions, are there any news on this becoming an official option though?
     
  12. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Not really. There are related changes to better support runtime rigging packages coming, but I'm not sure if would help in this case. The SimpleAnimation package was created by the animation team here, and is supported, and I would expect any solutions built around it to continue to work.

    As for playabledirector Pause/SetSpeed/Hold issues, no changes are coming in the immediate future, but it is on the backlog to address.
     
  13. axxelart

    axxelart

    Joined:
    Jun 28, 2020
    Posts:
    17
    Hello there. I know this post is really old, but I wanted to make my contribution because I have found something interesting regarding this.

    While I was experimenting with timeline components, I concluded that there IS a way to make the animation stop where it is during the timeline using the playableDirector.Pause() function instead of using playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0).

    To do this, you have to reproduce these steps :
    1 - Make sure the GameObject you wish to animate contains an animator component, WITHOUT an animation controller component: the reason why your GameObject resets in animation, is because the Animaion Controller automatically brings it back to the default state in it. You might also notice your object playing the default state animation instead of pausing if you put an actual animation in the default state.
    2 - Add an animation track in the timeline, and assign the GameObject you set up in there.
    3 - Press the red RECORD button, and change one of the properties of the GameObject in your scene slightly in order for the first keyframe to be created in the track.
    4 - Once the keyframe is created in the animation track, double click on the red area where the keyframe is to open the animation tab
    , and animate away.

    Now, when you test this in game after reproducing these steps correctly, you will notice your animations actually stop where they should.


    Additional Note : do NOT use playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0) to pause your timeline. I noticed there's a bug where if you pause for long enough and resume by setting the speed to 1 again, the soundtracks you might put in your timeline might not play again. That's because they indirectly are still playing on the same speed, and Unity thinks they have already finished playing. And so, Unity does not continue playing the sound file. This bug can still be reproduced in the latest version of the timeline package.

    The playableDirector.Pause() function is therefore the way to go. It actually pauses the sound tracks, and with the animation track fix above, it should also fix the animations.

    Meanwhile, if you feel you are forced to have a GameObject that has an animation controller with multiple animations, then make sure to use playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0) to properly pause its animations. Unfortunately though, you will have to create a separate timeline to pause the audio and use the playableDirector.Pause() function.


    I hope that cleared out some issues for some people :) there are quite numerous bugs in the Timeline component, and since I've been using it for quite a while, I know exactly what, when, and where to use it for in any situations.
     
  14. WhittS3

    WhittS3

    Joined:
    Sep 10, 2018
    Posts:
    4
    Thank you for this, just saved me much headache!