- Home /
Track time between
This is what i have setup so far, 3dtext with a box collider that says begin and another that says finish.
i would like to count the time it too the user to go from begin to end accurately
since Time.time starts as soon as the game begins, i would like to reset it to Zero when the player touches begin, and stop/ print the amount of time it took when they reached finish.
or create another system that can track the time from "begin" to "finish"
explained in another way: create a stop watch timer
Answer by StephanK · Jul 17, 2010 at 05:01 AM
When the player touches begin do this:
float startTime = Time.time;
to find out how long the actual game/round is running do this:
float curTime = Time.time - startTime;
Done.
ok for my "begin", i wrote:
float startTime = Time.time; function OnTriggerEnter (other : Collider) { guiText.text = ""+startTime; Destroy(gameObject); }
for the "finish" i wrote:
float curTime = Time.time - startTime; function OnTriggerEnter (other : Collider) { guiText.text = ""+curTime; Destroy(gameObject); }
but it seems there is an error in the finish script and i dont know how to deal with it
What happens? Are you destroying the gameObject that contains your guiText? I need to see your code to help you there.
it tells me a semi colon has to be inserted after the word "float", here is the error......... Timer Begin.js(1,6): UCE0001: ';' expected. Insert a semicolon at the end.......here is line 1......float startTime = Time.time;
in javascript the syntac is different. the line should read var startTime : float;
Your answer
Follow this Question
Related Questions
Accumulating deltaTime oddity 1 Answer
How to make a timer read to the .001 of a second 2 Answers
Minute Timer Issue 1 Answer
Time based scoring 2 Answers