#i didnt get your answer
1 messages · Page 1 of 1 (latest)
It means increase
yeah, specifically:
timer += time.deltaTime;
will add 1/second to timer
in update
can i reset it by timer = 0
yeah, that'll start it over again.
I use an extra step, so I can turn on and off the timers, and they don't start counting until I want them to:
i have this code
{
timer += Time.deltaTime;
if (timer > 5)
{
Rigidbody clone;
clone = (Rigidbody)Instantiate(projectile, Spawnpoint.position, projectile.rotation);
clone.velocity = Spawnpoint.TransformDirection(Vector3.forward * 20);
timer = 0;
}
```
is it good?
when I declare them, I define them as float.negativeInfinity, and then -only- increment them in Update if they are above float.negativeInfinity - so starting the timer then becomes setting it to zero in code, and stopping it is setting it back to float.negativeInfinity
☝️ ?
seems fine at quick glance
but dont ask me, I'm neither unity nor debugger
press play and find out!~
Good good. I thought for the longest time that this was.. the messy and dirty way to do timers, and the best was to do coroutines and ienumerators, recently learned timers like this are.. actually pretty performant