Timer.delay does not work after calling go.delete (SOLVED)

I have 2 objects. When they collide each other, both of them will be destroyed and I wait for 1 second to call function. I try print and it works but timer.delay not

1 Like

Yes, It says this in the documentation:

Timers created within a script will automatically die when the script is deleted.

I suggest you have the destroyed objects send a message to another script that will still exist 1 second later, and have that script use timer.delay.

5 Likes

thanks @ross.grams

1 Like

If I understand what you’re trying to do…

I normally would put in a custom function in an object script of “pre_death” or something, that would disable the object (or at least sprite/collison object/etc), and initialize a timer that has an anonymous function that just calls go.delete at the end. So instead of calling go.delete where you do now, call “pre_death.” Not sure if this is a “good” solution, but it works for me.

3 Likes