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

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

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

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

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.

1 Like

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 !

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.

1 Like

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().

5 Likes

PlayableDirector.Pause() will also call OnControlTimeStop in ITimeControl.
The workaround never call it so I was able to achieve my goal.

Thank you!

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?

You can try GitHub - Unity-Technologies/SimpleAnimation: A simple Animation Component that leverages PlayableGraphs. If you play an animation using that, it should overwrite what timeline is doing.

1 Like

Hi @seant_unity ! Thanks for the suggestions, are there any news on this becoming an official option though?

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.

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 :slight_smile: 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.

11 Likes

Thank you for this, just saved me much headache!

I don’t why we have to all spend hours finding the fix for this generally expected behaviour. UX issue 100%.