Hi guys,

I have a lap counter in my race that uses Time.time. I have it set to reset to zero (by subtracting the total lap times) at the beginning of each lap and it works fine… the problem is, at the start of each race, the counter is set to Time.time, so it is displaying the total time from when the game first ran.

What I’d like to know is if it’s possible to set a float, say fTimeSinceAppStart to Time.time’s current value but not keep updating every frame, so that I can reset the lap counter at the beginning of each race?

So then I could have the counter set to (Time.time - fTimeSinceAppStart) or something like that…

Sorry, this is probably REALLY obvious and I’m sure I’d normally get it a bit quicker but I have bee coding pretty much 20 hours a day, trying to get this game shipped and I’m tired! LOL.

like this:

var timeSinceStart : float;

function Update(){
counter = Time.time-timeSinceStart;
}

function StartNewLap(){
timeSinceStart = Time.time;
}

when you reset the time, call the function

EDIT:

by the way, here’s another method:

var counter : float;

function Update(){
counter += Time.deltaTime;
}

then you just reset counter at the lap, and it works!