Godot Version
4.3.stable
Question
I created a pause menu for the first time in Godot. I made it its own scene. While it works to some degree, it flickers between the game scene and the pause scene, though it will eventually land one of the scenes. Sometimes it’s the right one, sometimes it’s not. If I hold the assigned button down, it will flicker back and forth as long as it is pressed. Is this something funky with my inputs? Or something else? Any suggestions would be greatly appreciated. I’ve added the relevant code below.
Player script (in process)
#checking if game is unpaused and if the pause button has been pressed
if Input.is_action_pressed("selection_screen") and get_tree().paused == false:
#pause the game, switch to pause screen
get_tree().paused = true
get_tree().change_scene_to_file("res://select_screen.tscn")
Pause screen:
func _process(delta: float):
#checks if game is paused and pause button is pressed
if Input.is_action_pressed("selection_screen") and get_tree().paused == true:
#unpause the game, go back to the current scene
get_tree().paused = false
get_tree().change_scene_to_file(Globals.current_scene)
Also, if you know a better way to do this, by all means let me know. Always looking for new tricks!