Custom Animation Track

Hi,

To give a bit of context, I'm trying to setup a workflow to create cinematics during dialogs in our game. Due to the branching dialogues we plan to have timelineAssets per dialogue card and not the other way around.

We're are going to have 100s of cinematics if not 1000s.
The playable Directors could be anywhere but I think it makes sense to set them on the gameobject that will trigger them (NPC, Trigger, Interactable, etc..)

The cinematics need to blend seamlessly with gameplay (Top view, fixed camera angle).
The player is spawned at runtime.
It is important for us to be able to preview the cinematic in edit time to speed up the iterative workflow

I created a custom Track to spawn the player character (and other dynamic objects) while in preview mode, if it does not already exist in the scene.
I can get the preview character in my custom locomotion track used for moving, rotation, etc...
I have markers in the scene with keys such that I can easily get positions in the scene while previewing

So far everthing works as expected since it is all custom scripts...

My main problem is the Animation Track. I can't find a good way to animate my player character in the timeline because it does not exist outside of the preview mode.

I tried making a custom Animation Track by inheriting the default AnimationTrack but for some reason it does not record anything and it misses functionality like the TrackOffset and Override Track

The main reason I need a custom Animation Track is simply such that I can assign it to a specific character using a scriptable object reference. This way my custom track that spawns the preview character can set the animator binding reference during preview.

Another reason a custom Animation Track could be nice is simulating the animation that the player would have at runtime to test out different blending options in preview to see what works best for all scenarios.

(I also tried copy pasting the Animation Timline source code, but it has references to so many internal scripts that I gave up the idea)

Does any one have advice on how to make a custom Animator Track?

public class PuzzleAnimatorTrack : TrackAsset, ILayerable
{
public override IEnumerable outputs
{
get { yield return AnimationPlayableBinding.Create(name, this); }
}

public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
{
Animator animator= go.GetComponent().GetGenericBinding(this) as Animator;

foreach (var c in GetClips())
((AnimatorAsset)(c.asset))._animator = animator;

return AnimationLayerMixerPlayable.Create(graph, inputCount);
}

1 Like

Has there been any update for this? I would like to be able to do the same thing. Other than finding out about ILayerable, the response looks a little incomplete

1 Like

I have a similar issue, in which I want to have a track that has animation clips that are applied only to an animator that is created at runtime, assigning it in the editor is not possible. Also I want to remove the binding as it is not necessary.

I also tried to create an animation track from scratch, but I do not know how is the proper way to play the animation, since the ProcessFrame function is called each frame. This situation is still very difficult to address due to the lack of documentation about animation tracks. Do you have any advice?

I probably should give an update on this.
In the end I wasn't able to make a custom Animator Track.

Instead I made a custom TimelineAsset and a custom component that sits next to my PlayableDirector.
That allows me to scan through the entire playableGraph in it's creation and I can bind the Tracks to whatever I want. So in this case when I start the preview, I first spawn my character prefab and then assign it to the relevant Track binding. I know what the correct Track is thanks to TrackGroups and other custom Tracks that I use as Identifiers in those groups.

Not the most straight forward, but it works great for my use case