Capturing a time

Ha ha guys,

pretty sure i will kick myself when i see how its done
i have a timer counting up from when my car starts. and when i complete a lap it brings up the timer but keeps counting up. I just cant work out how to capture a time with delta time.

any info would certainly help me…Happy Friday!!!

Epoch!!! Hey, usually timers like this are just a float that counts up by Time.deltaTime as long as the race is on.

Then each time around the track you have a List that contains the lap times, and at the moment of cross the finish line to begin the next lap, add that time to the list.

At the end of it all, each lap’s time is just the difference between each lap datapoint.

And if you add zero at the start of the race, you can just iterate N-1 items, taking the difference between each lap datapoint.

List might contain:

0.0f, - begin race
10.0f, - end of lap 1
21.0f, - end of lap 2
33.0f, - end of race

Therefore your laptimes are 10, 11 and 12 seconds each!

1 Like

Ah yes thats great, i have it working on one lap, now to expand. Thanks a lot!

1 Like