Delay time in Godot

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

How can I make some delay time in godot? I’ve a game where the enemies have to attack in a specific amount of time. I’ve stored that amount in an integrer variable. ¿How can I make the enemy wait that time before attacking?

:bust_in_silhouette: Reply From: jgodfrey

The simplest way is probably to add a Timer to your scene. Set its wait_time to whatever delay you want. You can either start the timer manually from your code or set its autostart property to true to start it automatically. Finally, connect the timer’s timeout signal to your script. In the timeout callback, do whatever is necessary to start your attack (set a var, call a function, …)

Thanks a lot, it worked.

StJ | 2022-08-22 14:40