- Home /
timer that can be reset
hey everyone. im trying to make a variable that equals to Time.time and i want to have the ability to reset him,and he will start counting from zero,how can it be done?
the reason i want it to happen is so i could reset my animation and the var who actually controls the frame is index: index = Time.time framesPerSecond; (framePerSecond is doesnt really metters,in this question its just for the script to say how fast is the animation) so i want to reset the animation wen i switch to a new one,so i want a var who will replace the Time.time in 'index' so i can set him to zero when i start a new animation.how to do it?
thanks in advance!
Answer by zmar0519 · Apr 10, 2011 at 01:23 AM
try this:
var time : int;
private var lastUpdate : float;
function Update() { if(Time.time > lastUpdate) { lastUpdate = Time.time + 1; time++; } if(Input.GetButtonDown("Fire1")) { ResetTimer(); } } function ResetTimer() { time = 0; }
Your answer
Follow this Question
Related Questions
how to reset time 2 Answers
How can I read time from clip that is PlayQueued? 1 Answer
Unity3D Timer. 1 Answer
RotateAround x degrees over y time 1 Answer
How do you change a sprite after an amount of time? 0 Answers