I am making a custom tick system to suit my needs (calling normal ticks every 0.2 seconds, medium ticks every 5 seconds etc...)
I followed the tutorial in this video: CodeMonkey tick system tutorial
In his tutorial, he implements the tick counting as shown:
private const float tickTimerMax = 0.2f;
private void Update()
{
tickTimer += Time.deltaTime;
if (tickTimer >= tickTimerMax)
{
tickTimer -= tickTimerMax;
Tick++;
// Happens every 0.2 seconds.
OnTick?.Invoke(this, new OnTickEventArgs {Tick = Tick});
}
}
However, in other sources I have seen that instead of subtracting tickTimerMax from tickTimer, we just straight up set the tickTimer to 0, as shown:
if (tickTimer >= tickTimerMax)
{
tickTimer = 0;
Tick++;
}
It's hard to say if there's a big difference between these two methods, because at first glance they seem to do the same thing, but clearly they have their differences. So I'm wondering, which one I should use?