Week 2 - Checkpoints and lap counting


For week 2, I have implemented one major feature for my game. That being, the ability to count laps and lap times. 

The lap count system involves a series of checkpoints, all number in ascending order (I.E 1 though to 8). Alongside this, a variable is stored on the player object, counting the number of the last checkpoint they ran through. 

The checkpoints are activated in a specific way, where after passing through a checkpoint, all other checkpoints are deactivated except for the direct next checkpoint, and the previous checkpoint (I.E if the player ran through checkpoint 5, the only checkpoints active would be checkpoints 4 and 6). This means that if the player was to skip a checkpoint in an unintended way, such as clipping out of bounds. The lap wouldn't count until they drove through the checkpoint again.


Alongside the checkpoint system, lap times are now recorded. A series of 2 integers are used, "Seconds" and "Minutes". Seconds is a float, and increments every frame by utilising Time.FixedDeltaTime, allowing me to calculate lap times down to the millisecond. Once reaching 60 Seconds, the Minutes integer is incremented, and Seconds resets to zero. The most recent lap is then displayed on screen, formatted to {Minutes}:{Seconds}.{Milliseconds}, I do not have a hours variable, as if I were to make a track that took hours to drive, it would get pretty boring (also the Minutes counter does not reset after 60 minutes, meaning if for some reason you took over an hour to complete a lap, you would just see something to the tune of 80:12.201).

Files

109gamebuld3.zip Play in browser
43 days ago