+3 votes

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

in Engine by (38 points)
recategorized by

1 Answer

+11 votes
Best answer

From code:

var _timer = null

func _ready():
    _timer = Timer.new()

    _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.

by (29,120 points)
selected by

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

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?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.