I have a car that uses a single track timeline to animate a car object’s position on a single axis. This track is very simple and contains 4 keys inside of an “Animation Track” that alter the car’s x axis. As there are multiple cars in the scene, I’d like to give each one slightly different parameters which means I want to be able to alter the values and time of these keys in the object’s Start(); before I Evaluate the PlayableDirector to start it.
How can I access the keys from code from the PlayableDirector?
This is as far as I got:
director = this.GetComponent<PlayableDirector>();
TimelineAsset timelineAsset = (TimelineAsset) director.playableAsset;
TrackAsset track = timelineAsset.GetOutputTrack(0);
AnimationTrack animTrack = (AnimationTrack) track;
GameObject binding = (GameObject) director.GetGenericBinding(animTrack); //The GameObject this track is binded to (The car)
var animator = binding.GetComponent<Animator>();
//Something needs to happen here to get the AnimationCurve from the animator I think?
AnimationCurve ac = new AnimationCurve();
ac.keys[1].time = 10;