how to set delay by set_wait_time?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bgegg
extends Sprite
func _ready():
func _process(delta):
var timer =

this is not work.
how to delay print?

i checked this tutorial

:bust_in_silhouette: Reply From: wombatstampede

Your example is different from the tutorial. Also, the tutorial is for Godot 2.x. (although I don’t think it is any different in Godot 3.x).

You have to connect a handler function to the timeout event of the timer and you should add the timer as a child to some node. That is all shown in the tutorial you linked but you omitted it.


  • create timer
  • set timer parameters
  • add as child node
  • connect to handler function
  • do something in the handler function when the time was elapsed
  • if you don’t set one shot, then the timer function will repeatedly called
  • start the timer

You don’t want to do this in the _process function because this is called every frame. So you’ll end up with 60 timers created per second!

You can also interactively add a timer to the sprite in the node tree. And add a handler function to the timeout (see node tab of timer node). Then you just have to start the timer when needed, or check autostart when you want the timer start on the nodes creation.

What you didn’t understand:
Timer calls a function on timeout. It doesn’t halt (like a delay).

If you want a function to pause and wait for some time, then continue you can use “yield”:

one example (from the link above):

# Wait 5 seconds, then resume execution.
yield(get_tree().create_timer(5.0), "timeout")

i try this tutorial all

bgegg | 2019-04-26 11:17