Additive tracks in the timeline

For those looking at this look up override tracks in timeline. Does what you need to do

Nope, this thread is about additive tracks, not override tracks.

Was this ever added in the end? I see it’s been discussed for a few years. We’d need it in our project as well.

2 Likes

Can you describe your approach further? Not necessarily code examples but the rough outline.

1 Like

Hey, does timeline support additive layers now? It would be really helpful to fix motion capture animation clips directly inside Unity. It would allow very lightweight pipeline for realtime motion capture. As far as I know there is just override animation track. Any hint on how to implement an additive animation track for the timeine?

We had this same problem, this is actually doable with a custom track and the AnimationLayerMixerPlayable class. Takes a bit of figuring out that it’s possible though.

Here is a POC:

using System;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Playables;
using UnityEngine.Timeline;

[Serializable]
[TrackClipType(typeof(AnimationPlayableAsset), false)]
[TrackBindingType(typeof(Animator))]
public class AdditiveAnimationTrack : TrackAsset, ILayerable {

    public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount) {
        return AnimationMixerPlayable.Create(graph, inputCount);
    }

    public Playable CreateLayerMixer(PlayableGraph graph, GameObject go, int inputCount) {
        // This mixes the the first layer as override ("base" track) with all the other layers as additive.
        AnimationLayerMixerPlayable layerMixer = AnimationLayerMixerPlayable.Create(graph, inputCount);
        layerMixer.SetLayerAdditive(0, false);
        layerMixer.SetInputWeight(0, 1f);
        for (uint i = 1; i < inputCount; i++) {
            layerMixer.SetLayerAdditive(i, true);
            layerMixer.SetInputWeight((int) i, 1f);
        }

        // Create an output to the Animator
        PlayableDirector director = go.GetComponent<PlayableDirector>();
        Animator controller = director.GetGenericBinding(this) as Animator;
        AnimationPlayableOutput playableOutput = AnimationPlayableOutput.Create(graph, "LayerMixer", controller);
        playableOutput.SetSourcePlayable(layerMixer);

        return layerMixer;
    }

}

With this you can add animations to your track, and if you want additive animations create a layer (right click → add layer) and add the additive animations there.

There may be a better way to do this, but at least this is a starting point.

EDIT: Also tried extending an AnimationTrack directly instead of TrackAsset, but with that, the CreateLayerMixer method doesn’t work properly, “something” resets SetLayerAdditive to false for all layers.

10 Likes

Thanks for sharing that should be a great help! I just can’t make it work in my projet. I can’t add any animation clip neither on the principal AdditiveAnimationTrack nor on the layers. I’m on Unity 2021.1.7f1 and Timeline 1.5.5 what about you? I’m looking for finding where the problem is.

.7155232--856537--upload_2021-5-19_14-4-32.png

EDIT : I can add an AnimationClip if I change the class heritage to AnimationTrack like this

public class AdditiveAnimationTrack : AnimationTrack

But layers can’t add key, they can only import AnimationClip so far like the main layer… I need to add keys to fix the AnimationClip in the main Layer. Any ideas of why the key don’t write? Fields that I change are maked red as recordable but when I change values it does not write the key.

Hmm, I’m on Unity 2019.4.18f1 and Timeline 1.2.17. Try to change the false in the TrackClipType attribute to true. Doesn’t change anything for me but maybe it was a bug in my version of timeline (plus I’m creating the clips from code so for me it doesn’t matter).

Changing it to AnimationTrack won’t work, since it won’t use Additive but Override for the layers. Unless that was also "fixed. As for keyframing / recording, you got me there, I only used it to add clips, not modify them.

1 Like

Uh you’re right it becomes “override” instead of “additive”. Changing to “true” does not change anything too bad… if only we had additive animation layers in Unity we would not use Maya at all to fix motion capture and to do round-trips everytime :frowning:

It must be possible and I’ll find how! Thanks your hint it was still helping :slight_smile:

EDIT :

Changing [TrackClipType(typeof(AnimationClipPlayable), false)]
Into [TrackClipType(typeof(AnimationPlayableAsset), false)]

Allow me to add clips in an additive mode. Now I just can’t record anything of these tracks, with keyframing neither on the main layer or children layers (There is no red button). I’ll look for that and tell you if I find :slight_smile:

1 Like

Ah cool, I edited my answer if anyone comes across it, nice find.
I’m also confused why Unity doesn’t already support this in it’s animation track. With this layer mixer it should be straight forward, and they could just add a dropdown / checkbox on the track to switch between “Override” and “Additive” mode (since now it always forces Override).

1 Like

I confirm importance of this feature for the world of non stantart applicaton of Unity!

i make dmx512 light control sequencor on Unity - and this feature a last mile for me . It’s not possible to use timeline in ergonomic way, when you have to place given channel on fixed track - and as the lower animation track with clip on it turn off the control from the same anination clip asset from upper track

POC above work as proof of concept but it is still a bit glitchy for me, when i start move play cursor fast from one position of timline to other in preview mode (and this is key moment to create precise light sequence), values from are holded in nonzero value when timeline cursor leave animation clip, even if it zero at the end of the curve.

i very , very need for this feature.

1 Like

update to my prev.

As i am 10hour noob in Unity, it takes me 3 hour to understand that ILayerable implemented methods invent the ability to ADD LAYER on right mouse clik at the track - and if i use one track and several layers - i get the GLITCH FREE situation.
As i use pre generated library of clips for every channel value move - unity timeline seems like ideal sequensor with mixed control concept - i can work in raw channel-value control mode (with the ability of visualization in unity in parralel with artnet udp sends to real hardware) , and in the same moment i can place at timeline control events to start some generative algorythms or even send executive commands to stage crew )) . And all of this in sync with sound track and can be precisely adjusted in time.
I dont know yet how it will work for 1.5 h show and thousands clips on timeline, but Unity is the best that i have in comparision with other sequensors

Squeazer, Thaaanks !!!
Unity team - please read this consideration, it’s a new market for you, there’s not so large effort to implement some features - to get new app fields for Unity.

1 Like

Awesome! Thanks for the script. It’s working perfectly on my end. However, it always takes the base layer anim clip’s first frame transform position as 0,0,0 even though that frame has a different position value. So it’s not taking the transform values as it would on a normal animation track.

Any ideas on how to get that to work with this script?

well…now iam 20hr noob in unity timline )) so…

here’s the another dig in point for me , just to understang TL architecture.

Aftert that tutorial i decide additive track problem on my own with creating my custom track and clip (but i loose ability of curve editing, not a problem for me) with the following steps.

1)Create custom clip as editable from GUI parameters holder (may be there’s the way to provide “curve asset” to parameter in easy way i don’t now yet)
2)Create custom playable behaviour as runtime parameter acceptor from clip
3)Create custom track and custom mixer as weighted adder of current playable behavour values
4) [TRICK POINT] attach to the animated game object script component that working in two phases:
ph.a) accept calls of some AcceptValueToSumButCheckForFirsTimeCallForCurrentFrame(values) from all track mixers on all tracks ( from override ProcessFrame method of PlayableBehaviour )
ph.b) in update() method just provide accumulated values to game object
p.s. also need some state management to prevent value latch effect.

so i loose curve editing ability , but receive cross track mixing and high level of customization of mixing logic (not only sum)

1 Like

@seant_unity any update on Additive Layers for Timeline Animation Tracks?

1 Like

Same, started using Timeline and this is something that would make my life so much easier. Just figured out it is still not implemented :confused: Bump for the feature of additive animations, or Animation layers…

1 Like

You are life saver, this script is doing exactly what I need. I don’t get why Unity can’t add it as standard and it is so low on priority.

1 Like

That script was a life saver!!! Thank you!!!

1 Like

It somewhat functions, but rather than being additive, it overrides the entire animation.
image

You do it like this.

But position of transform is not working. (offset is not working, dont know how to fix it)