GUIText Timer

Hi there guys,
So I am working on a 3d platform game where I need a character with the tag “Player” to collide with one Trigger with the tag “Start” to start the timer and timer to end when the “Player” collides with the tag “End”.

I just have a regular timer working at the start of the game currently.

function Update () {
	GetComponent(GUIText).text = parseInt(Time.time).ToString();


Thanks in Advance :slight_smile:

I’m not sure if I got your question right, but I’ll give it a shot anyways.
Basically, you want to create a boolean called isCounting or whatever you like, and a float called timer.

var isCounting : boolean = false; 
var timer : float = 0f;

After that you create your update function which will do the counting.

function Update () {
      timer += Time.deltaTime;

And last you create your trigger function, which will check what collider you hit and change ‘isCounting’ accordingly.

function OnTriggerEnter (col : Collider) {
   if(col.tag == "Start")
      isCounting = true;
   if(col.tag == "End")
      isCounting = false;

And that’s it, put these three together and it should work, hope this helps :wink: