Issue with Game Pausing while in Menu

Godot Version

4.1.2

Question

I’m trying to create a crafting menu in my game that completely pauses the game and allows the player to move items around and craft items.

func resume():
	$crafting.hide()
	get_tree().paused = false

func pause():
	get_tree().paused = true
	$crafting.show()

func craftUI():
	if Input.is_action_just_pressed("crafting") and !get_tree().paused:
		pause()
	elif Input.is_action_just_pressed("crafting") and get_tree().paused:
		resume()

func _process(delta):
	craftUI()

The issue I’m having is that some of my crafting menu functions like tweens and placing items on top of another item to combine them are not working due to the game being paused. Is there a way around this?
My crafting menu control node (which contains the UI elements and is what is displayed when the crafting menu button is hit) and item scenes have all of their process modes set to When Paused.
I have heard that you can enable the PhysicsServer even while the game is paused but I’m having a hard time understanding how that works.

Set the process mode of your menu to “when_paused”. Id also recommend reading the docs on tweens and see if they have any parameters you can set to true when the game is paused

I had the same issue, but found out you can pause the time scale which did the trick for me:

to pause, use Engine.time_scale = 0
to resume, use Engine.time_scale = 1

1 Like

I’d recommend against this. How are you creating your tweens? using get_tree().create_tween() will bind the tween poorly, try using node.create_tween() or self.create_tween() instead. Are you reparenting nodes to drag and drop? Could you reparent them to a when_paused node?

1 Like

What do you mean by reparenting them? The way I have it set up is that each item is either an Area2D or a RigidBody2D that has their process mode as when_paused, and they are all children of a Node2D that also has the process mode as when_paused. Even when doing this, the signals from the Area2D and RigidBody2D still don’t work on game pause.

Have you tried also setting their disable mode to “Keep Active”?