Hey, a part of my game is a 100 meter dash and I need a stop watch for this part. The time should start counting when the player collides with the startline object and stop when the player hits the finishing line collider. In the Questionarea I’ve found the following code. It is counting, but only in the inspector. It does’nt stop atm. Any ideas how I can manage it? Greetings.
var Timer : float = 0;
var IncreaseTime : boolean = true;
var Start : GameObject;
var Ziel : GameObject;
function Update () {
if(IncreaseTime == true)
{
Timer += Time.deltaTime;
}
}
function OnCollisionEnter (Col : Collision) {
if(Col.gameObject.name == "finishingline_cube")
{
Time.timeScale = 0;
}
}