Hello everyone, I’m working on customizing timeline clips in Unity, but I’m confused about some concepts now. I’m not sure what Playable, PlayableGraph, PlayableBehaviour and Playable Clip are. I want to call a function when one clip starts and ends, but I don’t know which function I should call. Mine understanding of it is:
The whole timeline is “Playable”
this is the track as well as playable graph
and this is the clip and playable behaviour
I’m trying to control AI in the timeline, change NPC’s state and make it move to somewhere when the clip starts and return to idle state when it ends. Why I make it a clip instead of a marker is that I want to adjust its speed by changing the clip’s duration.
So many playable classes does make it confusing - I keep forgetting the exact details. I am not 100% sure, but I suspect you have to put markers (signals) on the tracks to get a function called at the start and end - I don’t think there is a callback function for some reason. (But I could be wrong!)
The way I generally remember it is clips are for the editor to use - all the details you can set in the editor when using the UI. Tracks also have a track asset that stores all the clips on disk (you have to tell it the clip type and binding type if binding is supported).
When you run the playable, PlayableBehavior’s do the actual work (the clip details get copied over into them). But you can blend between clips, so you need a mixer to combine them (if your tack supports it). I think PlayableGraph are the innards to coordinate creating all the playable and mixer - it does lifecycle management. But I will admit mixers still confuse me - there are some Good YT videos around.
Hopefully someone can answer with more definitive answers, but the above was my understanding in case it helps.
Thanks for replying. I know how to add markers, but I want to adjust the enemy’s speed by only changing the playable’s duration and that’s why I choose a clip instead of two different markers.
The track binding is not available in OnBehaviourPlay and OnBehaviourPause. You can access the binding during ProcessFrame (as playerData). ProcessFrame is called on each frame, for each active clip.
For some strange reason, we can’t get the bound object like in ProcessFrame. Currently, you can only pass a reference to PlayableAsset in CreateTrackMixer of PlayableTrack, and then pass it to PlayableBehaviour in CreatePlayable.
public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
{
foreach (var clip in GetClips())
{
((clip.asset as CustomAsset)!).NotificationManager = go.GetComponent<PlayableDirector>().GetGenericBinding(this) as NotificationManager;
}
var scriptPlayable = ScriptPlayable<CustomMixer>.Create(graph,inputCount);
return scriptPlayable;
}
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
{
var scriptPlayable = ScriptPlayable<CustomBehavior>.Create(graph,tmp);
scriptPlayable.GetBehaviour().notificationManager = NotificationManager;
return scriptPlayable;
}
Could you please tell me why I can’t get the bound object in OnBehaviourPlay and OnBehaviourPause? I really don’t see what’s the benefit of doing this. So that we have to use all kinds of weird ways to get this object.
Seconding this, I wanted to change an animator trigger from a timeline and without it it would just kept changing the trigger when used in ProcessFrame.