Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Question Animator Track : Keep animation looping when paused

Discussion in 'Timeline' started by VincentPaquin, Feb 10, 2022.

  1. VincentPaquin


    Sep 20, 2021
    We are currently working on a dialog system which would use Timeline as the main tool for placing cameras, characters, and pre-visualisation.

    The idea is that a track will pause the timeline, (or set the speed to 0, in order to "keep updating" the timeline), allowing the player interaction to happen.
    However, we would like certain animations to keep going ; Idle, for example, should continue playing.

    It is extremely similar to the Creative scripting for timeline blog post, which does the following :

    However, the timeline pauses only when there is no clip in the AnimatorTrack. If it does, the character freezes in place like so :

    I am still a beginner on scripting for Timeline and Playables.

    I feel like
    The ideal solution would be a way to get the AnimationClip to keep going, ignoring the pause. This would make use of AnimatorTrack's complex programming which handles scene offsets, default human poses, blending from AnimatorController to AnimatorTrack, etc...

    The sensical solution for me seems to be a custom track, but so far, I can't seem to understand how I am meant to play an animation clip, despite using Unity's Timeline Playable Wizard.

    The not-as-good solution could also be to have a monobehaviour on the character that can recieve animationClips and does the overriding itself ; making it dependant on gameTime instead of the director's time.
    Last edited: Feb 10, 2022
  2. VincentPaquin


    Sep 20, 2021
    I have tried accessing the playable at runtime, manually setting the time of all the playables except "Timeline" to Time.time during LateUpdate.

    In order to be still evaluated, the PlayableDirector is paused by using
    Code (CSharp):
    1. playableDirector.playableGraph.GetRootPlayable(0).SetSpeed(0);
    According to the playableGraph, the time is correctly set

    (Green means a playable that has the time set to Time.time, red means a playable that has the Timeline's time)

    However, the character is still frozen, as it seems during the graph's evaluation, the AnimationOffset and AnimationClip times are being set by Timeline.

    Manually Evaluating the graph after setting the times doesn't change the result, either.
  3. S_Affi


    Oct 27, 2018
    Have you found the solution?

    I'm also in the same boat. I tried creating custom animation playable track and it works as intended. But it doesn't play animation while in editor window, which is not a good thing while working on large time consuming project!
  4. VincentPaquin


    Sep 20, 2021
    Hi S_Affi,
    the characters now have a component that allows to create layers and add animation clip playables. It took a long time to do.
    It creates a new playable graph that includes the original AnimatorController as the layer 0, so I can add animations on top of the AnimatorController, blending "away" from it. It proved useful in a lot more cases. (Doors contain their "open" animation, and transfer it to the player when interacted with, for example).
    Then, a custom timeline track controls this component.
    Note that both the component and the timeline track have a lot of "if(!Application.isPlaying)" to have behaviours that allows them to play in edit mode.

    The timeline is paused using the code I posted above.

    I wouldn't mind sharing the code... But it isn't legally mine, apologies.

    the component is basically a worse version of the asset Animancer.
    Last edited: Sep 20, 2022
  5. liyueyueniaoguangjun


    Oct 17, 2019
    you can create new animation track by code.
    it create a PlayableGraph to contral you actor.
    i finish the system in 2021 to solve timeline and game logic fit