Timer operation. Every second event

Godot Version 4.2.1 Mono.

Question:

I have the 3 timers:

private float freezingTimer = 0;
private float burningTimer = 0;
private float poisoningTimer = 0;
public override void _PhysicsProcess(double delta)
{
     freezingTimer = Convert.ToSingle(Godot.Mathf.Clamp(freezingTimer - delta, 0f, 10f));
     burningTimer = Convert.ToSingle(Godot.Mathf.Clamp(burningTimer - delta, 0f, 10f));
     poisoningTimer = Convert.ToSingle(Godot.Mathf.Clamp(poisoningTimer - delta, 0f, 10f));
}

I want to make it so that after every certain time (like a second or half a second, whatever I want), I have an opportunity to perform a certain action, in my case call the damage function. How can this be tested?

why not using a timer node instead?

This design coped with its “test tasks”, and I didn’t see the need to make a timer node, since I didn’t know how to track every second anyway. If you know how to track, show me, I’ll rewrite it for the godot timer

My solution:
Replace the regular timer with a tick timer.
Set the number of ticks of the object, the base time of one tick.
Start the timer at a time equal to the base time of one tick and make a check, if there are still ticks, then take away one and start the timer again and so on until the ticks run out.

I’ve just opened this thread to tell you that.

You should’ve inherited from timer and make your own.
I’ve done something like that on my project. :slight_smile:

Is the new implementation better now?