Error: "Resumed function '_process()' after yield, but class instance is gone".

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Suleymanov
func _process(_delta):

Works perfectly well until I try to change or reload current scene. Then it returns this error: “Resumed function _process() after yield, but class instance is gone”.

Is there any simple workaround?
I honestly like the simplicity of yield(get_tree().create_timer(time),"timeout")
Is there a method maybe to control it?

Thank you for your time!

:bust_in_silhouette: Reply From: Suleymanov

Just made a simple one myself. In case somebody needs it:

var startCounter = false     #starts counting when true
var wait = 3.7     #you want your stuff in how many seconds
var a = 0     #counter variable
func _process(delta):

    #here you set the time limit (customize to your needs)
    #by setting startCounter to false, you reset timer

    if startCounter == false:
        a = 0
        if a < 10:
            a += 1 * delta

    #start the counter and do your stuff when counter equals your desired wait time
    #set startCounter to true or false to your needs

    startCounter = true
    if wait >= a:
        #do your stuff here

You can also use a Timer node. gdthonking

exuin | 2021-03-13 18:19