func _process(_delta):
# Quit game on esc press.
if Input.is_action_just_pressed("Quit"):
change_cursor_mode()
func change_cursor_mode():
if Input.MOUSE_MODE_CAPTURED:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
elif Input.MOUSE_MODE_VISIBLE:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
I want it so when the escape key (Quit button) is pressed it will change the mouse mode from captured to visible or vise versa, but it only goes from captured to visible but not the other way around.