- Edited
I have created an inventory/quest/system menu, that pops up when the user presses the "ui_menu" button that I have mapped to the Enter key, and the Start button on my gamepad. I want this menu to close when the same button is pushed again. The problem is, the menu opens and then closes before I can even see it. My guess is that the input is being processed by the player code, and then also by the menu code.
How can I get the menu to stay open? Is there a different way I should be handling the input for the UI?
Below are the scripts for the player, and the menu, some things removed for brevity.
player.gd:
func _physics_process(delta):
if Input.is_action_just_pressed("menu_button"):
if get_tree().is_paused() == false:
ui_menu.show()
get_tree().set_pause(true)
emit_signal("menu_open")
menu.gd:
func _physics_process(delta):
if menu_open == true:
if Input.is_action_just_pressed("menu_button"):
if get_tree().is_paused() == true:
get_tree().set_pause(false)
self.hide()
menu_open = false
func _on_player_menu_open():
menu_open = true