Run Update at a constant framerate in a single script

I have a ghost script that replays a users car movement. If it records at 30FPS and then performance increases to 60FPS the recording plays twice as fast.
Is it possible to tell my update in my ghost script to run at like 15 FPS?

I don’t require a high FPS as the tween between frames is fine. Also the 30 and 60 FPS are just example numbers.

The rest of my game can run at whatever FPS it requires but I want my ghost script to be fixed so the replay is always the same speed.

Will FixedUpdate do what I need?

Thanks

Yes FixedUpdate will do what you need.

Instead of FixedUpdate you may want to use a custom fixed update callback.

FixedUpdate can do the trick, it runs at 50 FPS with default fixed timestep setting, wich is 0.02. Or you can use coroutines for this. Like following pseudocode:

void StartPlayback(){
       StartCoroutine(Playback());
}

IEnumerator Playback(){
       do {
              ///////////////////////
              // playback logic here
              ///////////////////////
              yield return new WaitForSeconds(1f / 30f);
      } while (playbackNotFinished);
}

void StopPlayback(){
       StopCoroutine(Playback());
}