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.
Can you describe your approach further? Not necessarily code examples but the rough outline.
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.
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.
.
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.
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
It must be possible and Iâll find how! Thanks your hint it was still helping
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
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).
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.
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.
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)
@seant_unity any update on Additive Layers for Timeline Animation Tracks?
Same, started using Timeline and this is something that would make my life so much easier. Just figured out it is still not implemented Bump for the feature of additive animations, or Animation layersâŚ
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.
That script was a life saver!!! Thank you!!!
It somewhat functions, but rather than being additive, it overrides the entire animation.