using System; using System.Collections.Generic; using UnityEngine; public class StartFinishLine : MonoBehaviour { ShipControls ship; // timing... List lapTimes; List sectorTimes; double lapStart; void Awake() { Debug.LogError("SpaceRace!"); Debug.LogError("WSAD - Strafe"); Debug.LogError("Mouse 1 - Thrust"); Debug.LogError("Mouse 2 - Decelerate"); Debug.LogError("Space - Respawn"); Debug.LogError("F10 - Exit"); 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.LogError("Lap Complete " + other.gameObject.name); double lapTime = Time.timeAsDouble - lapStart; lapTimes.Add(lapTime); TimeSpan lapSpan = TimeSpan.FromSeconds(lapTime); Debug.LogError("Time " + lapSpan.ToString("c")); } void OnTriggerExit(Collider other) { Debug.LogError("Starting Lap " + other.gameObject.name); lapStart = Time.timeAsDouble; } }