How to pause all scripts except one in a node

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

In GD Script, how do I pause all scripts in a node except that one that called the pausing?

func example1():
      #code
func example2():
      #code
func example3():
      #pauses the other two functions
      #code
:bust_in_silhouette: Reply From: Inces

make some boolean var, like paused, end use it like this :

func example1() :
     if paused == true:
            return
:bust_in_silhouette: Reply From: jgodfrey

To pause the entire game (physics and all), you’ll want to call this:

get_tree().paused = true

To ensure that a node or scene can still operate while the game is paused, be sure to set its pause_mode property (just via the inspector) to process. That’ll allow it (and any of its children assuming their pause_mode is inherit) to ignore the pause.

To unpause, just call:

get_tree().paused = false

There’s an example in the docs.