Changing PlayableDirector time while paused (859251)

Hey, I recently started using PlayableDirector and I found, that while playable director is stopped using playableDirector.Pause() you cant set the time using playableDirector.time .

Is there a way to change the time while paused ?
(btw I cant change the time first and then pause it, I need it to be paused in the first place)

After setting the time you will need to call director.Evaluate(); or director.DeferredEvaluate(); We do this in the Timeline Window when setting the director’s time via the playhead or the time field while previewing.

2 Likes

Hi @grahamsaulnier
I have a question that after we call director.Evaluate();, does the timeline affect to game object in world immediately. And we can get correct game object position.

Yes.

Let’s assume you have an Animator and a PlayableDirector. Bind an AnimationTrack to the Animator and set the track’s infinite clip to a simple linear curve.

EditorCurveBinding transformXCurveBinding = EditorCurveBinding.FloatCurve(string.Empty, typeof(Transform), "m_LocalPosition.x");
AnimationCurve simpleCurve = AnimationCurve.Linear(0, 0, 1, 1);
AnimationUtility.SetEditorCurve(track.infiniteClip, transformXCurveBinding, simpleCurve);

So with this curve, at time 0 the x coordinate of the transform is 0, at time 1 x is 1.

If you then change the director’s time and call Evaluate, the transform will be immediately updated.

director.time = 1;
director.Evaluate();
// animator.transform.position.x is now 1