I am still pretty new to unity but I have managed to implement every other aspect in my car racing game except for the laps. Can someone please explain a simple way to implement laps in a car racing game. Thanks in advance.
link text hey follow this link for complete working solution ,it will redirect you to youtube on Polynurb’s tutorial and i found it very useful enjoy…also you can download polynurb’s project as a sample Cheers…if found useful dont forget to tick mark ENJOY…
In previous projects where I made a Race track, I used “control points” which was actually invisible gates that the player has to drive through. So place out some big enough planes around the track which allows the player to drive through.
To make sure that the player can not cheat, you have to develop a system that checks that the player is taking these control points in a specific order that you set up.
So lets say each check point has a boolean. The boolean is true if the player has run through it, false otherwise. So if the player runs through a check point, and the previous checkpoint is true, then this checkpoint is also true. If the previous checkpoint is false, then this checkpoint will also be false.
When the player drives through goal, the lap value will only increase if all checkpoints are set to true.
If they all are true, reset them by setting them all to false and add +1 to the number of laps the player has.
Example:
Game starts. Laps are set to 0, and the player starts to drive. The player reaches checkpoint 1.
Since Laps are 0, that means that the player has just started, so we can set the checkpoint 1 to true.
Player reaches checkpoint 2. Since Checkpoint 1 is true, we can set the checkpoint 2 to true.
Player reaches checkpoint 4. Since Checkpoint 3 is false, we will NOT set the checkpoint 4 to true, and keep it set to false.
Player reaches goal. Since Checkpoint 3 and 4 are false, we will NOT add +1 to Laps since all checkpoints aren’t set to true.
The player has to go back and get those checkpoints, or run a extra lap and getting the checkpoints in the right way.
Option:
To avoid the example Fattie gave below, that driving backwards four times, will add +1 to Laps, you can reset all checkpoints every time you go through Goal.
Doing this a player cant go back and re-take missed checkpoints after driving through goal and realizing this, and have to drive a complete track to get +1 to Laps.
So using this option, is a question of how you want to design your gameplay.
Player drives through Checkpoint 1, 2, 3 and 4 and reaches goal. Since all checkpoints are set to true then we add +1 to Laps and set all Checkpoints to false, and so on.
Good luck!