Pausing
Godot has a built-in pausing system that can be used to pause the game. This is useful for when you want to pause the game when the player presses the pause button.
-
Create the pause menu scene.
-
Set the process mode to
When Paused
in the scene. -
add the pause menu to the scene tree and hidden it.
-
Add the following code to the script of the main scene.
func pause(): get_tree().paused = true $PauseMenu.show() func unpause(): get_tree().paused = false $PauseMenu.hide()
-
Connect the pause and unpause functions to the pause button.