I’m in the process of making a drag racing game. i have a timer that starts my tree activation sequence (the 3 lights the light up sequentially before the green light) then logging the reaction time when the car leaves the starting line trigger. and as of now it works, however it only logs in ever .02 seconds and i need to much higher resolution to measure the time. reaction time is usually measured to the .00x of a second and sometimes a race is won to the .000x of a second. how can i make the timer read at a higher resolution? i know my code probably isnt the cleanest and most efficient as i am a beginner game maker but im understanding it better now.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RightTree : MonoBehaviour
{
public MeshRenderer Yellow1Off;
public MeshRenderer Yellow2Off;
public MeshRenderer Yellow3Off;
public MeshRenderer Yellow1On;
public MeshRenderer Yellow2On;
public MeshRenderer Yellow3On;
public MeshRenderer GreenOff;
public MeshRenderer GreenOn;
public MeshRenderer RedOff;
public MeshRenderer RedOn;
public IsStagedRight stagedR;
public DisqualifiedR disqualifiedR;
public RightTree treeActiveR;
public float timer;
public string seconds;
public Text ReactionRight;
private void Start()
{
Yellow1Off.enabled = true;
Yellow2Off.enabled = true;
Yellow3Off.enabled = true;
Yellow1On.enabled = false;
Yellow2On.enabled = false;
Yellow3On.enabled = false;
GreenOff.enabled = true;
GreenOn.enabled = false;
RedOff.enabled = true;
RedOn.enabled = false;
treeActiveR.enabled = false;
}
private void FixedUpdate()
{
if (treeActiveR.enabled == true)
{
timer += Time.deltaTime;
seconds = (timer % 60).ToString("f3");
timer = float.Parse(seconds);
if (timer == 1f)
{
Yellow1Off.enabled = false;
Yellow1On.enabled = true;
}
if (timer == 1.5f)
{
Yellow1Off.enabled = true;
Yellow1On.enabled = false;
Yellow2Off.enabled = false;
Yellow2On.enabled = true;
}
if (timer == 2f)
{
Yellow2Off.enabled = true;
Yellow2On.enabled = false;
Yellow3Off.enabled = false;
Yellow3On.enabled = true;
}
if (timer >= 2.5f && stagedR.enabled == true)
{
Yellow3Off.enabled = true;
Yellow3On.enabled = false;
GreenOff.enabled = false;
GreenOn.enabled = true;
Debug.Log(timer - 2.5f);
//log reaction time in text box
ReactionRight.text = (timer - 2.5f).ToString("f3");
}
if (timer < 2.5f && stagedR.enabled == false)
{
disqualifiedR.enabled = true;
Debug.Log(timer - 2.5f);
//log reation time in text box
ReactionRight.text = (timer - 2.5f).ToString("f3");
}
}
}
}