How to wait until function finish its task in class?

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

In my game i created one class that manage puzzle position n all.

class GemEngine:
      func _init():
               #process some variable.

     func sendInitPacket():

Now i want to call sendInitPacket after 1 second. How i can call this function or there is anyother way ?

:bust_in_silhouette: Reply From: ZBot

You need to use Timers.

var timer =

and call your

func sendInitPacket():

As the timer callback function or inside a timer callback function.

You can also add a timer to the scene itself but then the timer will only be called, when the scene loads.

I also recommend reading the full docs on the Timer class to tweak the settings there are plenty of customization options.