Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hi! I can show you some of the code I wrote to make the ghost car. I uploaded a simplified version so you can take a look: https://gist.github.com/RichoM/2b2856db3ae2e7f7fb4c0919eb9c00eb.

It’s actually very simple. The code that moves the player’s car will also store the player’s input for each frame in an object called Replay. Whenever a player beats its own personal record, I save its replay data so that I can use it later for the ghost car. Then, when running the ghost car, instead of using the player’s input I use the stored inputs from the replay. And I think that’s all there is to it. Let me know if you have any question.