0 votes

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
asked Aug 16, 2016 in Engine by apekke (21 points)
edited Aug 16, 2016 by Akien

2 Answers

+6 votes
Best answer

Try:

var t = Timer.new()
t.set_wait_time(3)
t.set_one_shot(true)
self.add_child(t)
t.start()
yield(t, "timeout")
answered Aug 16, 2016 by twinpixel (157 points)
selected Aug 17, 2016 by apekke

Don't forget to free the timer afterwards, or you'll cause a memory leak.

t.queue_free()
0 votes
answered Aug 16, 2016 by Akien (1,780 points)

Note that if you use those in the main thread, those will cause the project to freeze until the delay has expired.

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 How to use this Q&A? before posting your first questions.