How to handle mouse motion with captured mouse in Godot 4?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By erter11

I decided to move my project from Godot 3 to Godot 4 and I already made all code and nodes work in new version, with one exception, mouse movement input. It worked fine in 3.5 and it works now without captured mouse, but when mouse captured it stop handling movement.

func _ready():
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _unhandled_input(event):
	if event is InputEventMouseMotion:
		print(event.relative)
		rotate_object_local(Vector3.DOWN, event.relative.x * rotate_speed * sensitivity)
		camera.rotate(Vector3.LEFT, clamp((event.relative.y * rotate_speed * sensitivity), MIN_ROT_Y, MAX_ROT_Y))
		camera.rotation.x = clamp(camera.rotation.x, MIN_ROT_Y, MAX_ROT_Y)

Output of event.relative is always (0, 0, 0)

:bust_in_silhouette: Reply From: erter11

I found what was the problem. In the center of screen was a GUI element of type ColorRect with the “Mouse/Filter” property set to “Stop” by default. After switching to “Ignore” everything works fine.