ghost replay system as for a racing game ?

I am trying to get a replay of an object to play when I load a level.

Therefore it will need to be somewhat saved beforehand and loaded upon level load. I have a 2D bike game, like a side scroller, and I would like to have a replay of my bike racing alongside me like a ghost. I have no idea how to go about it.
Thank You in advance.

To be honest, you should realize this is far from easy.

Are you a beginner programmer or do you have years of experience?

Yo begin, you need absolute mastery of all forms of lists, arrays and the like.

Essentially, you do just save the position of the vehicle every (let’s say for now) 0.2 seconds.

Leter, you play it back.

(If you’re asking “how to make it transparent looking” that will be the least of your problems, look in to transparent shaders and so on.)

Some of the issue that arise

  • I casually say 0.2 seconds above. This is not unlike saying “to play real time video over the internet - download the data !!!”. In practice you often need a real-time heuristic system that determines of it’s own accord what Hz you have to use, as the system is in use

  • you need have total mastery of interpolating on the fly - not unlike the difficulties that arise when you do a realtime multiuser racing game.

  • I mention List, it could be a rare case where performance is so demanding you have to use a raw array and all the problems that arise with managing those dynamically (if you were programming at a lower level, like in XCode, it becomes a huge thing about memory management, juggling how much is available, how much you can use, how many are playing, blah blah)

  • when you play back as I casually mention above, you have all the problems of playing two things in sync (the ghost replay and the current driver), again not unlike engineering RT MP games.

  • when i say save the “position” it’s often very complicated, you may need to save the rotation, weapons, bones, damage, whatever … a big hassle.

For example a buddy’s company has worked on ghost systems for racing titles, you’re talking €100,000s man-hour jobs.

All that being said …

in a word, it’s as simple as: use List to save the position (etc) at a regular interval, and then play that back.

Unity makes things incredibly easy, so you could get something going, but just be aware you’re taking on an impressive challenge. There’s a reason that dozens and dozens of full-time engineers work on gran turisimo, you know! Heh!

For very broad questions like this you may find much more information on general game development sites

I have created a script for this exact scenario:

Let me know if that helps