#i didnt get your answer

1 messages · Page 1 of 1 (latest)

olive forge
#

what do you mean

#

increment?

nova sluice
#

It means increase

carmine crater
#

yeah, specifically:

#
timer += time.deltaTime;
#

will add 1/second to timer

#

in update

olive forge
#

can i reset it by timer = 0

carmine crater
#

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:

olive forge
#

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?

carmine crater
#

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

carmine crater
#

seems fine at quick glance

#

but dont ask me, I'm neither unity nor debugger

#

press play and find out!~

olive forge
#

ill tell u if somethin is wrong

#

everything is kind of good

carmine crater
#

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