Swapping between Multiple TimelineAssets per PlayableDirector

I currently have a custom state machine system controlling an Animator for a fighting game I'm working on.The end goal is to animate character's hitboxes (defined in Unity by game components) in tandem with imported animations from Maya/3DS Max. The supposed "normal" way to go about influencing game elements via the animation system would be add custom curves or animation events to the imported animations, or alternatively using Mecanim's Sync Layers with in-engine animations. However given the number of hitboxes to control per character, this quickly becomes a very poor workflow and a painful developer experience. I'd much rather create a separate Unity animation clip and overlay it with imported animations via Timeline, which would support scrubbing through a "combined" animation.

I've experimented with a single timeline, and it works well with one Timeline clip: one attack. Scaling it further to add more timelines is seemingly doable with PlayableDirector.Play(PlayableAsset) and Evaluate, but I seem to be running into a wall where the PlayableDirector needs to have bindings for every track possible across all timelines. These bindings can indeed be generated at runtime, but it breaks the editor workflow, which is the entire reason I'm trying this option out.

Is this an appropriate use case for Timeline? or am I missing some other alternative to achieve the same goal?

Tangentially related: this UI combobox suggests that multiple timelines can be stored or managed by a single PlayableDirector, akin to that of the Animation window. There seems to be no documentation on the actual use of this control, at least to my knowledge, can someone clarify how to use this?

If I understand correct what you are trying to do will work. And you are right, the playable director does need to have bindings for each track across all timelines it might play. Reassigning timelines should not cause it to forget old bindings.

You can use PlayableDirector.SetGenericBinding() to assign the bindings (the parameters are the track and the binding), even before the timeline is assigned. You should be able to assign them all manually as well, if that was easier.

That control lets you switch which PlayableDirector is currently shown, not which timeline is on the playable director. Although you do bring up an interesting use case.

I see an issue with your animation approach of hitboxes. I suppose that you are using humanoid rig for different characters using the same animations. The humanoid animator takes care of different rig sizes of your avatar, but your hitbox animations would not adapt to different rig sizes. So all your work will be futile. Correct me if I am wrong.

Looking around the forums, it seems that it's a common use-case to have a track of a given name bound to a target: use the string name of the track as the common key to match tracks to outputs, rather than use the reference to the track as the key, similar to that of animation parameters and states within the animation system. I'm normally not for this kind of solution since it leaves larger room for human and machine error, making said systems harder to test, but there are indeed tangible benefits to such a solution.

If I were to use PlayableDirector.SetGenericBinding from an editor script, will the changes be saved?

Also is there a way to clear the all the saved bindings on the PlayableDirector without going into the Debug mode inspector?

@msl_manni_1 : The hitboxes are unique on a per-character and added within Unity, and are not meant to be retargeted across characters. Most of the properties animated are the script properties and not the actual collider or transform, so long as the animations do not alter the scale of the rig it should be fine.

You may have to flag the scene as dirty manually, but yes using PlayableDirector.SetGenericBinding in editor script should save the changes.

And no, there is no way to clear the bindings (other than debug mode). That's probably something that should be added to the API.

It will be interesting to see a video of your project. Specially on the unique hitboxes per character approach. :)

I seem to have it working just fine. However, I seem to have lost the ability to blend between states as a result. What is the best way to blend the last X seconds of one Timeline with the first X seconds of another?

Use the ease-in/ease-out properties on the first and last clips on your timeline. That will blend with whatever else is playing.

So PlayableDirector.Play(PlayableAsset) will respect the ease-in/ease-out settings of both previous and new TimelinesAssets? Does calling PlayableDirector.Evaluate remove this blending? Because I don't seem to see it working.