- Home /
Make a Lapping System for a Car Game
I am making a car game. Right now, it is just a car game where you just drive around and jump of ramps. I was thinking of using OnColliderEnter on invisible boxes to establish waypoints scattered around the track. then when the car passes through say, 10 of them, it makes a var increase by 1. Then when that var has reached a max of 4 or so, then it displays a GUI saying YOU WIN!. This could then be used to make a simple tracking system to determine which car is in the lead. But i do not want to create a AI trakcing systme yet so yea..
I am not asking for a complete code, that would be nice, but not necessary. Just a couple pointers in the right direction, maybe just a couple bits of pseudo code.
Thanks, - Jordan
Answer by Stormizin · May 28, 2013 at 01:27 PM
You can count a lap each time a Collider with tag "StartPoint" is hited, and compare if is player. Like e.g:
var laps : int = 0;
function OnTriggerEnter(other : Collider) {
if (other.CompareTag("Player"))
laps++;
Debug.Log("I've completed " + laps + " laps.");
if (laps == 3 )
Application.LoadLevel(1);
}
Your answer
Follow this Question
Related Questions
AI car Script problem 1 Answer
AI Car Problem 1 Answer
How To Add AI To Car/Racer? 4 Answers
How to implement traffic system efficiently in Unity game to run smoothly on mobile device? 1 Answer
Car AI Avoiding Obstacle 0 Answers