Pause menu not Unpausing

Godot Version

<Godot version 4.2.2>

Question

I’m trying to setup a toggle function that will show my pause menu and pause the game and when the InputEvent is pressed again it will hide and resume the game.

Currently everything but the hide menu and resume game function is working. I can’t seem to wrap my head around why.

pause_menu.gd script:
“”"
“”"
func _on_game_manager_toggle_game_paused(is_paused: bool):
if (is_paused):
show()
else:
“currently not hiding the menu and resuming game”
hide()

“”"
“”"
func _on_resume_pressed():
game_manager.paused_menu = false

“”"
“”"
func _on_quit_pressed():
get_tree().paused = false # Ensure the game is not paused when transitioning to the main menu
get_tree().change_scene(“res://Scenes/Menus/StartScreen/start.tscn”)

menu_manager.gd script:

class_name GameManager

signal toggle_pause_menu(is_paused : bool)

“”"
“”"
var paused_menu: bool = false:
get:
return paused_menu
set(value):
paused_menu = value
get_tree().paused = paused_menu
emit_signal(“toggle_pause_menu”, paused_menu)

“”"
“”"
func _input(event : InputEvent):
if event.is_action_pressed(“pause”):
paused_menu = !paused_menu

“”"
“”"
func resume_game():
get_tree().paused = false
emit_signal(“toggle_pause_menu”, paused_menu)

When you call get_tree().paused = true, all nodes that still have the Process > Mode property set to the default value Inherit stop receiving input events. There are several ways to resolve that. Check out this tutorial that demonstrates one of them.

2 Likes

Thank you for your tutorial! I was able to get my resume functionality to work using your viewport() method while attaching it as a child node to the menu scene tree. Currently ran into another bug where the first Input press pauses, second unpauses, but when I try to pause again I need to double press my “pause” input. It might be my sudo-toggle getter and setter. Time to put some time into that!