Im thinking that lots of things i want to check regularly do not need to be checked every update. Would it make sense to use InvokeRepeating to througout the objects existence call SlowUpdate() every second (for example). Is there a better solution?
Well, of course there is FixedUpdate, and if even that is running through too many iterations, too quickly, you could simply add a counter within FixedUpdate (since you at least know that’s happening at a constant rate) for example:
public class Example : MonoBehaviour {
public int slowUpdateCycleLength = 10;
private int slowUpdateCycle = 0;
void SlowUpdate()
{
// ....
}
void FixedUpdate() {
if ( (slowUpdateCycle = ( slowUpdateCycle + 1 ) % slowUpdateCycleLength) == 0 )
SlowUpdate();
// ....
}
}
FixedUpdate is only for physics and isn’t guaranteed to have a constant framerate (despite the name). InvokeRepeating is indeed a good choice…you could use a coroutine, but InvokeRepeating has slightly less overhead.
–Eric