0 votes

i have a smal window in a size like a smartphone because i want to export it later to android. but also i want to play my game on windows too.

the player shoots in direction where the mouse cursor is, but godot cant find the direction if the cursor is outsite of the window.

can i bypass that?

in Engine by (68 points)

You probaly should do this different: Try to develop two versions: For PC and android which have different window settings.

No i don't. its a realy smal skill game. it isn't suposed to run in FullScreen.

2 Answers

0 votes

Relying on the mouse cursor outside of the actual system Window sounds like a bad idea, both technically and UX-wise. Godot can't catch events happening outside of the window, unless the mouse is in a dragging operation (which is an actual feature of window managers).
If you want your game to run properly, the best you can do is to make the window larger or resizeable, really. That doesn't mean you have to resize the game area: for this you can change the scaling modes if you want it to remain the same size. If you relied on OS window size in your code, then that's also a bad idea since that assumption can easily break due to varying mobile resolutions anyways.

by (27,962 points)

Other games do the same thing if you run them in window mode.
Gamemaker Studio does have that ability too

And i think godot also has that ability and ich just want to know how.
There must be an workarround

Which games do that? How would they even handle clicks outside the window? (which means the window will vanish out of focus :| )

It is possible to get the global mouse position on screen using OS-specific APIs, but that's not a feature available through Godot API. Nobody needed this before.

GTA 5 for excample.
and you cant click outsite of the window. you need to swap off with alt + tab

every game that you run in window mode disables the ability to click outsite of the screen.

there are always in nearly every game the ability to run in window mode or to run in borderless windowmode. but your cursor doesnt ever move outsite the window.

i just want the same thing. you aim in mousedirection and you should still aim in that direction if the mouse leaves the window.

it would be enough to disable the ability to leave the window.

i think


is nearly that what i am searching for.

0 votes

It might be old but:


will not let the mouse move outside of the window
This is used in this 3d demo for looking around:

by (14 points)
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 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 webmaster@godotengine.org with your username.