How do I store a time value in a variable.
Hello I want to display the time that the player took to complete a level. I am currently using
winText.text = "You Won in "+Time.time+"seconds";
but the time value is not constant. How do I store the time at the instant when this code was initialized?
Comment
Answer by Zoogyburger · Feb 14, 2016 at 02:38 AM
You might want to take a look at this: http://unity3d.com/support/documentation/ScriptReference/Time.html here's an example:
var levelTimer : float;
var updateTimer : boolean;
function Start()
{
levelTimer = 0.0f;
}
function Update()
{
if (updateTimer)
levelTimer += Time.deltaTime;
}
function LevelEnded()
{
updateTimer = false;
}
Your answer
Follow this Question
Related Questions
Problem with a stopwatch 0 Answers
How do I do math in unity.(timer/60 and timer%60) 1 Answer
How can I record the time that has passed between mouse clicks? 1 Answer
Milliseconds Timer Question 1 Answer
Timed button pressed C# 1 Answer