How to call a method only every 1 second?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Irul
:warning: Old Version Published before Godot 3 was released.

How to call a method only every 1 second? Preferably using Timer node.

:bust_in_silhouette: Reply From: Zylann

From code:

var _timer = null

func _ready():
	_timer =

	_timer.connect("timeout", self, "_on_Timer_timeout")
	_timer.set_one_shot(false) # Make sure it loops

func _on_Timer_timeout():

You can also do it all from the editor: create Timer child, set same properties, then open the Node tab, and connect the timeout signal to _on_Timer_timeout.

Hell… Why I didn’t think of it :D. Thanks man.

Irul | 2016-10-19 13:05

In addition to this, how could the method be called every OS time second? Or maybe better: how could this timer_start be yielded until the next OS time second?

pferft | 2021-04-19 13:18