MOUSE_MODE_CAPTURED doesn't lock the cursor for editor-spawned game windows

Godot Version

Godot Engine v4.2.1.stable.official [b09f793f5]

OS Information

Ubuntu 23.04 / Wayland

Question

When running my game from the editor and setting the input mode to Input.MOUSE_MODE_CAPTURED, I can still move the cursor outside of the window. This only happens when running the game from the editor, and not when running an actual build.

Why is this happening? How can I fix it?

Relevant Code

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

It may be because you are using Wayland. Open an issue here Issues · godotengine/godot · GitHub explaining the problem and giving as much info as you can.

1 Like