Blending between Timeline AnimationTrack and Animator

Hello!
I would like to share my technique to blend between Timeline’s Animation Track output and Animator Controller’s output.

As you may know, if one set AnimationPlayableOutput.SetWeight(), then you can blend animations between different graphs. However, Timeline is also setting the output weight during the PlayableGraph evaluation as well, so simply setting weight out from PlayableGraph won’t make any work, as for it will be overwritten by Timeline itself.
So, what one can do, is to add another Playable to the graph, to re-rewrite the weight. An example is like this:

    public class SetAnimationOutputWeightBehaviour : PlayableBehaviour
    {
        public float weight;
        public List<AnimationPlayableOutput> outputList = new();

        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            // set weight
            foreach (var output in outputList) {
                output.SetWeight(weight * output.GetWeight());
            }
        }
    }

If one add the PlayableBehaviour into the graph, the weight will be setted every frame.

Here(Github) is the full script of the TimelineAnimationWeightSetter. Attach the script to the same gameobject of the Timeline(PlayableDirector), then you can set the weight of Timeline animation at any ratio. (same as the gif img above)
You can leverage this technique to add systematical animation fading-in fading-out between Timeline and Animator, to make the transition look good.

8 Likes

you help me a lot! Thanks boddy!

Thank you. you saved me!

2022.3.23f1 No problem