How do I track mouse movements outside a border-less game? I need this function, because I want players to explore the environment by moving the camera via mouse movement.
The closest I’ve gotten to it is by having the mouse pressed down constantly, but that causes other issues as well in my game.
You could set the moude mode to capture so it can never leave the window or you can use
get_global_mouse_position() which I think will give you coords outside the game window, as long as the window still has focus. If you lose focus, it is technically a bad thing to keep tracking the mouse, you know? =P
Hmm, I tried
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED), but none of them captured the mouse movements outside the window.
Input.set_mouse_mode(Input.MOUSE_MODE_CONFINED) worked better, but stopped detecting the mouse movements once it hit the border.
Also, why is it a bad thing?
Getting mouse coords from outside the game can be used to leak information that a malicious program could use to log mouse movements and infer security information about a computer, so it is pretty normal for engines to just not attempt it, and it’s also possibly blocked at the window-manager level.
You can use a combination of confined and captured modes, and near-edge area detection to do the appropriate actions before the mouse leaves the game window. Including moving the mouse cursor back in. But there is nothing that does, or should, prevent the user from leaving the game area, or a game could theoretically steal the cursor and prevent the user from using it for normal operations, so when your window loses focus, you’ll see you also lose captured mode, for example.
Ah I see, guess I’ll have to settle with Confined mode + exponential camera movement. Thanks for the help +++