Search code examples
godotgdscript

How to invoke a function on unpausing the tree?


Is it possible to invoke a function or connect a signal when the tree is unpaused?

for example I have this setup:
enter image description here

the world script:

extends Node2D

func _ready():
    get_tree().paused=true
    
    # do something
    
    get_tree().paused=false

the thing script:

extends Node2D

func _unpaused():
    # reset something when the tree is unpaused

is something like this possible?


Solution

  • No, I can't find a signal or virtual method for that.

    I'd say use an autoload that controls paused, and make sure everything on the projects that needs paused goes through the autoload. So the autoload can do whatever you need when it changes.