So, is there a built-in function to GDScript where I can pause a process in a script for a few seconds, say:
set_visible(false) wait(1) #waits for 1 second set_visible(true) #then continues the rest of the script after the 1 second wait
Try:
var t = Timer.new() t.set_wait_time(3) t.set_one_shot(true) self.add_child(t) t.start() yield(t, "timeout")
Don't forget to free the timer afterwards, or you'll cause a memory leak.
t.queue_free()
See OS.delay_msec and OS.delay_usec.
Note that if you use those in the main thread, those will cause the project to freeze until the delay has expired.
yield(get_tree().create_timer(1.0), "timeout")
Does the timer created here get disposed?
I believe that, once the routine has been resumed, the SceneTreeTimer object, returned by the create_timer () function, becomes invalid, as documented at: https://docs.godotengine.org/en/3.0/getting_started/scripting/gdscript/gdscript_basics.html?highlight=yield#coroutines-with-yield