So I’m making a top-down strategy game and I want the units to have a delay between shooting, so that the unit don’t just disappear because their firing every few milliseconds. I would prefer not to use a coroutine, but if I have to I guess I will.
Thanks.
If you do NOT use a coroutine, then you can keep a float that simply counts up Time.deltaTime every Update() and when “enough time” has passed, then do whatever it is you want to do.
Properly architecting it with coroutines will probably be a LOT more maintainable however. Learn them and love them and embrace them. They are your friend throughout time for any type of “gameplay process” that doesn’t happen all in one single frame.
1 Like
public float canDo = -1f;
if (time.time > canDo )
{
//do task
canDo = time.time + delay;
}
Invoke(“function”, 1f)
executes function after 1 second. Simpler than using delta and delays 