Hello there,
I am trying to understand better the logic of timers and what is the best practice. Until now I used something like this: I set a waitTime, I increment a number in the update function, if the timer is above waitTime then the time is over.
waitTime = 10;
void Update()
{
timer ++;
if (timer > waitTime)
{
timer = 0;
Debug.Log("time is over!");
}
}
I could use also Time.deltaTime to increment the timer variable. For what I understand the difference between this two practice is:
timer++ increment every frame by 1,
timer+= time.deltaTime increment every frame with the time passed between one frame and the previous.
In both case if my game is lagging the time will lag also.
If I put everything in the fixedUpdate() and i use Time.fixedDeltaTime my timer will increment regardless of my framerate, but I don’t think I want something like that. If I am using a timer to change the state of my player from poison to normal I think the time should be adjusted with the framerate…
As you see I grasp the idea, I would like to know what is the best practice in your opinion.