Finished all cars, and took lap times on them all
This commit is contained in:
32
Assets/Scripts/LapTimer.cs
Normal file
32
Assets/Scripts/LapTimer.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LapTimer : MonoBehaviour
|
||||
{
|
||||
public float time = 0;
|
||||
private bool startTime = false;
|
||||
|
||||
|
||||
private void OnTriggerEnter(Collider other) {
|
||||
|
||||
if (startTime)
|
||||
{
|
||||
startTime = false;
|
||||
print(time);
|
||||
} else {
|
||||
startTime = true;
|
||||
time=0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
|
||||
time +=1;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user