|
|
|
|
Reply From: |
Inces |
You can yield for anything that is an object.
You can wait for nodes function until it is completed with return, You can also wait till some node emits a chosen signal. These are usually very handy for controlling flow of various game phases. In the same way You can wait for your timer node to emit signal “timeout”, which every Timer node has built in. FOr this :
var T = ( reference to your timer here )
yield(T,"timeout")
However there is no sollution to avoid error when yielding instance is gone. It is not crashing error anyways. However You can use TImers “timeout” signal normally, by connecting it to Your node and resolving it on_Timer_timeout(), just like all signals ever
Been trying an odd solution. Added AudioStreamPlayer with silent audio file with desired length, and used finished() signal to implement stuff which works without an error, but adds up unnecessary data (audio file).
Can you please guide me with an example? Before I used to do it this way:
yield(get_tree.create_timer(5),"timeout")
get_tree().reload_current_scene()
It worked but with errors. How would you do it with Timer?
Suleymanov | 2021-04-12 16:34
Your main goal is to avoid error when executable is gone ?
If so You should use basic signal properties, You should learn about them in tutorial and documentation, they are more basic than yielding
Basically both yield() and signal connected nodes “listen” to built in signals. If You pick any node in editor, on the right of Godot UI You can change inspector Tab to see its possible signals. If You click Timer node You will see a lot of signals like on-ready, exit tree, and so on, and one of them is “timeout”.
If You did it with AudioStream You should do it exactly the same with Timer node. Connect it, and instead of “finished” use “timeout” signal. Then set time and start the Timer. All methods for setting up Timer are in Godot help. I am not sure what kind of example You are looking for
Thank you for your help! Much appreciated.
Suleymanov | 2021-04-12 20:08