How to pause game

Godot Version

4.2

Question

so for my game i want to make it so that whenever the next level menu pops up everything in the background stops moving and fighting.
i have this:
func _on_health_component_before_death():
Global.level_change()
var level_menu = level_complete.instantiate()
get_parent().add_child.call_deferred(level_menu)
$“…/Spawner/food production”.stop()
$“…/Spawner/enemySpawn”.stop()
get_tree().paused = true
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
the problem with this is that whenever it pauses it will pause the level menu too so i cant press next level. How can i make it so everything but the level menu pauses

I implemented something similar in one of my games. The way I did it probably isn’t scalable well, but you can give it a shot. For every node I wanted to be paused, I added a variable called paused or something similar. Then, in the _process function, I added an

if not paused:
     regular movement

so that if the variable is true, the game is paused. Like I said, not scalable, but you could try it.

You are doing the right thing you just need to mark nodes that will not pause. See this

1 Like

Check out this tutorial:

1 Like