Option 1
Use process delta
- The fastest implementation but not entirely precise
#process time
export var count = 10
var delta_time = 0
func _process(delta):
delta_time += delta
if delta_time >= 1.0:
delta_time = 0
if count > 0:
count -= 1
print(count)
Option 2
User timer
- Or use a timer
- set it to 1 sec
- connect to the following script
infinite loop possible stack overflow
func _on_timeout():
count -= 1
if count > 0:
$timer.start()
Option 3
Use Yield or OS.get_ticks_usec()
or OS.get_time()