Pausing games and process mode


In most games it is desirable to, at some point, interrupt the game to do something else, such as taking a break or changing options. Implementing a fine-grained control for what can be paused (and what cannot) is a lot of work, so a simple framework for pausing is provided in Godot.

Wie pausieren funktioniert

To pause the game the pause state must be set. This is done by assigning true to the SceneTree.paused property:

get_tree().paused = true

Doing this will cause two things. First, 2D and 3D physics will be stopped for all nodes. Second, the behavior of certain nodes will stop or start depending on their process mode.


The physics servers can be made active while the game is paused by using their set_active methods.

Process Modes

Each node in Godot has a "Pause Mode" that defines when it processes. It can be found and changed under a node's Node properties in the inspector.


You can also alter the property with code:

func _ready():
    pause_mode = Node.PAUSE_MODE_PROCESS

This is what each mode tells a node to do:

  • Erben: Prozess abhängig vom Status des Elternteils, Großelternteils usw. Der erste Elternteil, der einen Nicht-Vererbungsstatus hat.

  • Stop: Stoppt den Node, egal was passiert (und Kinder im Vererbungsmodus). Wenn dieser Node angehalten wird, wird er nicht verarbeitet.

  • Verarbeiten: Verarbeitet den Node, egal was passiert (und Kinder im Vererbungsmodus). Egal ob angehalten oder nicht, wird dieser Node verarbeitet.

Standardmäßig haben alle Nodes diese Eigenschaft im Status "vererbt". Dies bedeutet, dass sie nur verarbeitet werden (oder nicht), je nachdem, welche Eigenschaft auf dem übergeordneten Node festgelegt ist. Wenn der Elternteil auf "vererbt" eingestellt ist, wird der Großelternteil überprüft, und so weiter. Wenn bei keinem der Großeltern ein Status gefunden werden kann, wird der Pausenstatus in Szenenbaum verwendet. Dies bedeutet, wenn das Spiel angehalten wird, wird standardmäßig jeder Node angehalten.

The _process, _physics_process, _input, and _input_event functions will not be called. However signals still work and cause their connected function to run, even if that function's script is attached to a node that has its pause mode set to "Stop".

Animation nodes will pause their current animation, audio nodes will pause their current audio stream, and particles will pause. These resume automatically when the game is no longer paused.

It is important to note that even if a node is processing while the game is paused physics will NOT work for it by default. As stated earlier this is because the physics servers are turned off. The physics servers can be made active while the game is paused by using their set_active methods.

Pause Menu Example

Here is an example of a pause menu. Create a popup or panel with controls inside, and set its pause mode to "Process" then hide it. By setting the root of the pause popup to "Process", all children and grandchildren will inherit that state. This way, this branch of the scene tree will continue working when paused.

Machen Sie es schließlich so, wenn eine Pause-Taste gedrückt wird (egal welche Taste), aktivieren Sie die Pause und zeigen Sie den Pause-Bildschirm an.

func _on_pause_button_pressed():
    get_tree().paused = true

To unpause, do the opposite when the pause screen is closed:

func _on_pause_popup_close_pressed():
    get_tree().paused = false