A Checkpoint System for Racing Games
This is a system that tracks the player around the course. It counts the total number of checkpoints to know when a lap is made. Math is also used to measure the distance between 2 checkpoints, with curves and straightaways.
Naming the Checkpoints
The system is a little complex, but it’s overall easy to use. The checkpoints work by changing the name of each checkpoint object in the object settings. The name is set by the next turn after the checkpoint as Middle, Right, or Left (M, R, L), then a dash “-” and its own value (1 - 89).
For example: “R-1”
Where do you need to place the Checkpoints?
You want to place a checkpoint at the beginning and at the end of every different turn (up to 180’). Turns that are 180 degrees need to be even, but you could also use 90 degree turns if they need to be uneven. It’s important that the objects are named correctly for these turns. It’s also very important to not overlap your checkpoints. Overlapping would count as a single collision, and you could end up skipping checkpoints, which this system does not allow.
Map Data and Position
The “Map Data” object is also needed for this to work. This object gets the data from all checkpoints and puts in several lists that the player and CPU’s can use. It’s also important for the names to be set correctly to get the Data in the correct order.
And also inside the Lap bundle is a score value that gets the distance of the checkpoint, total number of checkpoints, and the total number of laps. This score can be sent to an object to sort out all the scores between all the Racers, and give the player a position.