heya,
i am using
sam = Time.time;
to start a timer.
but it doesnt start at zero and it keeps going.
im trying to make a function to start a timer that goes from zero to 15 then resets itself back to zero again.
Struggling with this stuff but making some progress…
great forum.
cp
heya,
i am using
sam = Time.time;
to start a timer.
but it doesnt start at zero and it keeps going.
im trying to make a function to start a timer that goes from zero to 15 then resets itself back to zero again.
Struggling with this stuff but making some progress…
great forum.
cp
Time.time counts from when you started the application, so it’s not going to be zero. However, you can still use it in this fashion. When your timer starts, store Time.time in a variable (say, called startTime). In the Update loop, have something like:
if(Time.time - startTime >= 15.0) {
// reset timer here
}
to do your reset when it hits 15.
Alternatively, if you don’t need the precision of checking the timer every frame, you might want to look into using InvokeRepeating instead.
wow !
InvokeRepeating is just what i was looking for, maybe it is a bit like setInterval in flash, anyways, thanks so much!
CP
btw, do you have any suggestions how to learn this language? I would never have known to try , or even find, invoke repeating.
thanks again.
cp
hey there question for ya actually.
how invoke repeating is great.
how do i stop it though?
cp