Outputting Reaction Time Data

Hi everyone,

Im creating an experiment with a driving simulator in Unity. I need to record player reaction time as soon as they enter a trigger. My problem is that I don’t know how to get unity to provide me with a print out of the reaction time to each triggerevent.
Here is the code ive been using so far:

using UnityEngine;
using System.Collections;

public class ReactionTimer : MonoBehaviour {

class colliderWithTimer: MonoBehaviour
private bool isTiming = false;
private float timeTillKeyisPressed = 0;

void OnCollisionEnter(Collision collision) {
	isTiming = true;
}

void Update(){
	if (isTiming)
	{
		timeTillKeyisPressed += Time.DeltaTime;
	}
	if (Input.GetKeyDown(Keycode.S)) // I used S, but ofc this can be something else
	{
		isTiming = false;
	}

}

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

}

I was wondering if; a) this is correct for what I want to do and b) if there is a way so that the system will print out the reaction time to each event?

Thank you all very much!

If you just want to print out the time in the editor, use Debug.Log. If you want to see the reaction time in the compiled application you have to use the UI system. For Debug.Log something like this should work:

 void Update(){
     if (isTiming)
     {
         timeTillKeyisPressed += Time.DeltaTime;
     }
     if (Input.GetKeyDown(Keycode.S)) 
     {
         isTiming = false;
         Debug.Log("Reaction time: "+timeTillKeyisPressed+"ms"); //Or use UI here
         timeTillKeyisPressed = 0; //Reset timer
     }
 }