Topic was automatically imported from the old Question2Answer platform.
Asked By
carbajosa
Hi,
I have scripts that uses timers but through GDScript like so:
yield(get_tree().create_timer(time), "timeout")
I don’t quite understand if this script create a timer node in the scene tree and ‘clears’ itself out when the timer is out. Assuming I used this a couple of times in a single scene, will it slowdown my game?
This code creates SceneTreeTimer which is not a Node but a Reference. It means it will be destroyed once current function completes.
It is possible many of those Timers will be active at the same time if you call your function often and time is comparatively long. For example if you call your code 100 times per second and time equals 2s there will be up to 200 SceneTreeTimers at the same time.
But you don’t need to worry about freeing them.
Thanks for clearing that out. I use them for invincibility timers when the players get hurt.