I want to make a frame Independent Timer that it work consistently across different computer configuration.
1 Answer
\$\begingroup\$
\$\endgroup\$
2
// ORIGINAL TIMER COUNTDOWN IN SECONDS
const float TIMER = 3;
// TIMER CURRENT TIME
float Timer;
// RUNS ON EACH FRAME
void Update()
{
// SUBTRACT DELTA TIME FROM CURRENT TIME
Timer -= Time.deltaTime;
// TIMER WENT OFF
if (Timer <= 0)
{
//DO SOMETHING
Foo();
// RESET TIMER
Timer = TIMER;
}
}
-
\$\begingroup\$ so this will work frame Indepently and how can i speed up \$\endgroup\$ Commented Jan 27, 2016 at 9:32
-
\$\begingroup\$ @MohammadFaizanKhan you would change the TIMER value to whatever you want. I added some comments since you seem to be pretty new to this. \$\endgroup\$– jgallantCommented Jan 27, 2016 at 10:48
Time.timeScale
for slow-motion effects and the like. \$\endgroup\$