using System; using System.Collections.Generic; using UnityEngine; public class StartFinishLine : MonoBehaviour { ShipControls ship; // timing... List lapTimes; List sectorTimes; double lapStart; void Awake() { ship = GetComponent(); lapTimes = new List(); sectorTimes = new List(); } void OnTriggerEnter(Collider other) { // our timer is not running // either because we haven't started racing yet // or we respawned if (lapStart == 0) return; // we are completing a lap Debug.Log("Lap Complete"); double lapTime = Time.timeAsDouble - lapStart; lapTimes.Add(lapTime); TimeSpan lapSpan = TimeSpan.FromSeconds(lapTime); Debug.Log("Time " + lapSpan.ToString("c")); } void OnTriggerExit(Collider other) { Debug.Log("Starting Lap"); lapStart = Time.timeAsDouble; } }