+2 votes

I've read someone placing it back into the window whenever it leaves the border with the Input.warp_mouse() method.

But is there a proper way to lock the cursor inside the window?

in Engine by (28 points)

1 Answer

+2 votes
Best answer

I haven't tested it, but according to the Input class, you can use:


However, it also makes the cursor invisible, so you may need to render your own cursor at the mouse coordinates given.

by (5,264 points)
selected by

Yeah that worked, Thanks.
Plus seems I'll have to prevent it going off-screen as well

This doesn't seem to work if you export to html. In that case the mouse can still leave the window.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.