Hello. So I have a problem with a pause menu that I was working for my game. I can enter the pause menu by pressing the escape key and I can also exit the pause menu by pressing he escape key as intended. However, I can't escape the pause menu properly by pressing the resume button and I don't know why. When I test the pause menu in isolation from the player's FPS Controller, it's not a problem at all. It's only when I use the FPS Controller with the pause menu that it becomes a problem. It's hard to describe what actually happens when I press the resume button but, I got it on video; the image of the menu is still there yet darker, the player can do things with the FPS Controller except the turn with the mouse and the mouse isn't visible. In order to get of the pause menu, after pressing resume, I have to end up pressing the escape key again.
Can anyone figure out what the problem is? Here's the code for pause menu:
extends CanvasLayer
var paused = false
# Called when the node enters the scene tree for the first time.
func _ready():
if self.visible == true:
self.hide()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if Input.is_action_just_pressed("Pause"):
pause_menu()
func _on_resume_pressed():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
self.hide()
get_tree().paused = false
paused = false
func _on_restart_pressed():
get_tree().paused = false
get_tree().reload_current_scene()
func _on_quit_pressed():
get_tree().quit()
func pause_menu():
if paused == true:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
self.hide()
get_tree().paused = false
else:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
self.show()
get_tree().paused = true
paused = !paused
Here's a video of a tutorial I was following for the pause menu: