I’m trying to wrap my head around something that I think can’t be that difficult, but I haven’t found an approach yet that works.
Here’s what I’m trying to do: I have an AnimationTrack that contains 15 different clips that all animate the same object. The clips have some overlap so that they blend into each other.
Now I want to be able to, per each of these “sections” (the clip relate to environmental effects for specific sections of an experience), to override what they do. E.g. one of the sections has “animate the skycolor to red”, but I want the user to be able, at runtime, to override that with green, while still having the proper fades to the previous and next clips.
First thing I tried was to use a custom script to figure out the right weights each clip has and to apply the right override color based on these weights. That does not work for blending between clips, as the “original” color will start to fade in and I have no way to mix “previous clip color” with “override color”.
Second thing I tried was to create replacement Animation Clips with custom keyframes and put them into the AnimationClipPlayables at runtime when needed. This does not work at runtime since there is currently no API for creating AnimationClips that are compatible to timeline that works outside of the Editor.
Third thing I tried was having a custom Mixer/Track (since, after all, I want to mix the clips in a custom way), but that failed since even with decompiling the Timeline dll most of the interesting stuff (“OnCreatePlayableGraph”) is internal and cannot be overriden, so I can’t replace the AnimationMixer with my custom one. The only thing I can override is “CreateTrackMixer”, and according to decompilation, that’s not even used by the AnimationTrack class! It’s hardcoded to use AnimationMixerPlayable! … that would’ve been the right spot if not for that internal oversight.
Fourth thing I tried was doing it the “timeline way” and override the actual graph that is generated.
Currently it looks like this:
With the override (modifying the graph in PlayableDirector.played), it looks like this:
However, the issue with this approach is that the Timeline doesn’t set the weights on these three AnimationMixers, it still changes the weights of the clips. So, no luck again.
Fifth Thing was looking into the experimental AnimationStream. From what I found, it seems that these can be used in AnimationStreamPlayables that can modify the data running through them. This means I’m running into the same issue as with approach #4, of the Timeline not being able to set weights on something else than the actual AnimationClip unless I hack that in as well.
Any advice on what the right plan of action would be here? I guess the base question boils down to:
“How do I modify the output of an AnimationClip before it goes into an AnimationMixer, while still using the Timeline?”