while (DurationTimer < Duration){
DurationTimer += Time.deltaTime;
if (Ship.Shields < Ship.maxShields/2f){
Ship.RestoreShields(PrimaryEffect);
} else {
Ship.RestoreArmor(SecondaryEffect);
}
yield return new WaitForSeconds(.25f);
}
First off, I have no idea why the code pasted so weird with the indents…
Duration
in this case is 7f. I assumed this would then have this effect last for 7 seconds, where every quarter of a second shields are increased until 50%, then armor is increased. Looking into the documentation I’m seeing that deltaTime returns the time since the LAST frame… not the time since it was last called within scope. Sooooo… What’s a “good” replacement for deltaTime? Should I calculate my own delta time since the last loop in this coroutine, or should I have the coroutine yield WaitForFixedUpdate
and keep a second timer for controlling the restore calls? Or even better – is there a built in way of getting delta time from within a coroutine?