How to pause code

Godot Version

4.2.1

Question

I wanna pause my game. I tried to do it with this command:

get_tree().set_deferred("paused", true)

This method pause only physics_process function but I need to stop other functions as well. I also tried to do that by changing timescale:

Engine.time_scale = 0

This method works more better then previous one, but in that case I cant use tweens, which I used to animate pause menu, and this method doesnt stop events from pressing keys

Is it any solutions? Thank you in advance

1 Like

Answers should be here, specifically process_mode. It can be set per node so your UI can process even though your game isn’t.

2 Likes

Right, call get_tree().paused = true, while modifying process_mode for the pause menu to PROCESS_MODE_ALWAYS to prevent it from being paused.

Thus the children of the pause menu will inherit this configuration since the default value of process_mode is PROCESS_MODE_INHERIT.

I also encountered a tricky issue. When I use get_tree().create_tween(), the tween will be paused, however, the tween won’t be paused if the tween is created with this node.