Hi i am using this script on my car racing game. I have 6 checkpoints which i want to add time to a countdown timer. The 1st checkpoint adds time but the rest dont. The checkpoints are identical as i duplicated the 1st one (so they all have the same properties and tag) does anyone know where im going wrong? the code attached to the car is
var timer : Timer;
var TimeBoost : AudioClip;
function OnTriggerEnter(yes : Collider) {
timer.startTime += 30.0;
}
thankyou
have you tried debugging to test to see if the vehicle causes the function to be called in the other checkpoints???
Never thought it could be doing that! how do i debug? or could i just amend my script and give each checkpoint a dif tag?
what i would suggest is using
Debug.Log("Hey Look I Passed A CheckPoint");
in the on trigger enter - this will print to the console
then you can check if the function is being called
var timer : Timer;
You made a script called Timer.js or Timer.cs (whatever) and you put it in the timer variable, in the Inspector ?
The script attached to my gui text is
var startTime = 30.0;
var timeLeft : float;
function Update () {
//Time left before level is reset
timeLeft = startTime - Time.time;
//No such thing as negative time
timeLeft = Mathf.Max (0, timeLeft);
//Format time
guiText.text = FormatTime (timeLeft);
//When time is 0, restart level
if (timeLeft == 0) {
Application.LoadLevel (“IntroScreen”);
startTime = 30.0;
}
}
//Format time
//12(minutes):34(seconds).5(fraction)
var intTime : int;
var minutes : int;
var seconds : int;
var fraction : int;
function FormatTime (time) {
intTime = time;
minutes = intTime / 60;
seconds = intTime % 60;
fraction = time * 10;
fraction = fraction % 10;
//Build string according to format
//12(minutes):34(seconds).5(fraction)
timeText = minutes.ToString () + “:”;
timeText = timeText + seconds.ToString ();
timeText += “.” + fraction.ToString ();
return timeText;
}