Timer wait time 0.01 is not enough small
Timer wait time 0.01 is not enough small.
Pretty sure you can do it less than 0.01s...?
What about just doing a call_deferred and/or adding _fixed_process deltas instead?
I don't understand how call_deferred works.
If I understood correctly, 0.01 seconds is less than a frame (aka more than 60 fps), so how do you expect it to work? You can already set the Timer to use _fixed_process but even that would not work because the game doesn't updates fast enough. The only option I see is to set your game's framerate higher, or not using a timer since the timeout will happen before the next frame anyways.
You can do something like this, which is an approximation:
var interval = 0.01
var time = interval
func _fixed_process(delta):
time -= delta
# If the interval is smaller than a frame,
# timeout() can be called more than once per frame (beware of 0 interval though)
while time < 0:
time += interval
timeout()
func timeout():
# do stuff
I' am writing a scoreboard discount. As I see it, if I could setup the timer wait time in less than 0.01 I will allowed to update the label text 2 times between frames. I don't care if one this update is never seen. Your code is similar to Timer internal code; I don't want to reinvent the wheel. But your comment let me think, that I need a more efficient solution, thanks.
I don't see anything that can be implemented in Godot here, if you need to make operations faster than the game loop, you need to find some tricks which would be game specific (like setting the FPS to 120 and slowing down everything else..). But it mostly sounds like you're trying to implement bad design, if you need to change a label twice per frame, just skip the 1st change and do the 2nd one...