In gdscript, is there codes looks like "python's time.sleep()"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By nagne

I want to make code delaying time not using “timer node”. So is there codes in gdscript?

:bust_in_silhouette: Reply From: zhyrin


:bust_in_silhouette: Reply From: putper

You can use OS.delay_msec, but do read the disclaimer below it. It pauses the entire thread, possibly freezing your entire project.

In Godot 4 you can delay your code like so:

# wait 2 seconds
await get_tree().create_timer(2).timeout