Movable Timeline of NavMeshAgent movement?

Basically, after determining the path of my agent Id like to be able to save its movement and be able to scrub through a slider/timeline forwarding and reversing its movement. How would I go about this?

I know I have an array of Vector3s from the agent path, I’m just having trouble on how I’d about about implementing the movement.

There are a few options here, but the most straight forward approach is to create an animation clip from the path data you have.

You could use the GameObject Recorder (found here) to create an animation clip, or generate one yourself from the data.

Make sure the animation clip has ‘Generate Root Motion Curves at Runtime’ enabled. This is required to make it work correctly with timeline.

You can then manually create a timeline, or generate one from script as needed (see code below).

		var timeline = ScriptableObject.CreateInstance<TimelineAsset>();
		var track = timeline.CreateTrack<AnimationTrack>(null, null);
		track.CreateClip(clip);

		GetComponent<PlayableDirector>().playableAsset = timeline;
		GetComponent<PlayableDirector>().SetGenericBinding(track, animator);
		GetComponent<PlayableDirector>().Play();