I am working on a racing game, and was wondering how to implent replayable ghost data. My current idea is to add x and y values to a json file every tick/second value, and to set the ghost to go to the next point? (I don't know if this is possible/how this would be done.
Develop games in your browser. Powerful, performant & highly capable.
Here’s an old example of a way to do it with an array. Json would be pretty similar.
You might want to look at the Ghost Racer example in C3. Could be a good starting point.
I made a very nice ghosting system some years back.
Simply stuff all the data in a array, which you can use to loop through at a later stage.
I used to store the ghost runs in local storage (array.asjason) and pass it to other players in a network game.
Works pretty decent, looping through it; using moveto.
The array lends itself for easily adding extra data (timing/tick, angles, sizes, etc)
You can easy tweak how much data gets stored by either passing a timed interval (every x seconds) or somewhere in the midst of your code.