Why Coroutines but not normal function

Hello, in Laser Defender course, Coroutines are used for laser shooting. I know what the coroutines are for, but why instructor had choose coroutines for shooting? It can also be ok with normal function, why need coroutines in here any special reason?

Hi Pompei,

We do not want to shoot a laser each frame, thus we need a delay. We could create our own little timer in Update, or we could use a coroutine, which allows us the coroutine method to pause.

We do not need a coroutine. We need a delay, so we are able to shoot a laser every x seconds instead of 60+ lasers per second. How we achieve the delay is more or less a matter of personal preference.

Is this what you wanted to know?


See also:

Yes once again, thanks for the answer Nina.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms