- Home /
Created Finish line
Hi Guys,i try use this script
var laps : int;
function OnTriggerEnter (racer : Collider) {
if (racer.Controller.laps < 5) { laps++;} else if (racer.Controller.laps >=5) {winGame();}
}
function winGame () {
//do winning stuff here.
Application.LoadLevel("2"); //another level for instance.
}
But "Controller" is not member of Unity.Engine.Collider. How to fix it?
Answer by Statement · Jul 28, 2011 at 02:25 PM
If you want to get the controllers laps, try this. Change YourControllerType to whatever type your controller is.
var laps : int;
function OnTriggerEnter (racer : Collider) {
// Change YourControllerType to the type you use as your controller.
var laps = racer.GetComponent(YourControllerType).laps;
if (laps < 5)
laps++;
else if (laps >=5)
winGame();
}
function winGame () {
Application.LoadLevel("2");
}
Answer by ourchat · Jul 29, 2011 at 03:05 AM
Hi Statement...thanks for your answer...But my car still run :( You have idea for created Finish line and show lap count on GUI? For learn i use car tutorial from http://unity3d.com/support/resources/tutorials/car-tutorial.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612161150im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
racing game 1 Answer
AI Car Problem 1 Answer
How to display Car's Rank in a Racing Game 3 Answers
Problem getting vehicles to stick to the road in an F-Zero style game 1 Answer
Rankings in racing Game 1 Answer