Hi, I’m using [Transform Tween Track] in [Default Playables] asset to move Player’s transform position.
Could I set the “Start End” values through code in runtimes?
because I want to reuse this timeline assets on different targets.
For example, I have several doors, which can be triggered by Player,
each one has several clips to move player step by step.
What should I do to access different clips’ “start location” “end location” like ClipA ClipB ClipC on one Track in the picture below?
Here’s an example of how to set all exposed references to the same target (class/variable names may not be accurate…)
// grab the timeline asset from the playable director
var timelineAsset = playableDirector.playableAsset as TimelineAsset;
// get the list of output tracks of the target type
var tracks = timelineAsset.GetOutputTracks().OfType<TransformTweenTrack>();
foreach (var track in tracks)
{
Debug.Log(track.name);
// go through all the clips
foreach (var clip in track.GetClips())
{
Debug.Log(clip.displayName);
var tweenClip = clip.asset as TransformTweenClip;
if (tweenClip != null)
{
// grab the property name from the clip
PropertyName prop = tweenClip.startLocation.exposedName;
// assign the object through the playable director
playableDirector.SetReferenceValue(prop, targetObject.transform);
}
}
}
director.SetReferenceValue(ttc.startLocation.exposedName, data.startingPos);
director.SetReferenceValue(ttc.endLocation.exposedName, data.endingPos);
However my exposed reference name are identically equal to 0
so it changes both fields.
Shouldn’t they be serializefields or when we create a clone of the playable recalculated with a different id
It’s working but i’m not sure if i’ve done it properly.
Just to be clear i’m using a control track to manage several instances of the same timeline asset and i’m settings up the bindings and the reference value of my tracks at runtime.
For example i have a timeline where the player’s characters are joining the field, but i don’t know how many characters were selected by the player then they will taunt/cheer ( all of my timelines asset are stored in a sciptable object as a database of timelines )
So to make it work i added the initialization of those properties of each one of my stored timeline used in my scene. (before their instantiation )
Its seems that it will be expensive. How could i do this as a default behavior, like before their serialization maybe i’m sorry i’m not an expert ? In the transform tween track or clip, or i the playable asset ? Also after play mode, inspectors of my tracks seem to be broken.
In inspector debug view there are two main differences, once is that my asset id changed
and the other one is that my main playable director kept all my scene bindings and exposed references. how can i clear them.