Any ideas why this does not work?
I start off with MOUSE_MODE_CAPTURED, and can switch to MOUSE_MODE_VISIBLE.
Once that happens, when I use “cancel_mouse” it only returns MOUSE_MODE_CAPTURED (the print statement executes) no matter how many times I try, but it is not actually Captured - it remains Visible.
func _ready() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
mouse_motion = -event.relative * 0.001
if event.is_action_pressed("cancel_mouse"):
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
print("visible")
else:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
print("captured")