Before updating to Windows 10 you may need to return your Pro license. More information here

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!

more ▼

asked Apr 10, 2011 at 12:12 AM

avatar image

27 19 14 15

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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; }

more ▼

answered Apr 10, 2011 at 01:23 AM

avatar image

1.1k 166 128 144

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Apr 10, 2011 at 12:12 AM

Seen: 2126 times

Last Updated: Apr 10, 2011 at 01:24 AM