Hide cursor on game startup

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By two_headed_goblin
:warning: Old Version Published before Godot 3 was released.

Hi!, i’m currently working on a dark adventure game in Godot, for inmersion purposes i’ve decided to create my own cursor which is a hand. I’m using an animated sprite that follows my mouse around and is working great.

Only issue i have is that the mouse shows when i start the game, until the user moves it at least one pixel.

This is the code i use upon cursor initialization
enter image description here
The cursor is a singleton global that is loaded on the proyect globals

This is how it looks when i start the game

This is fixed when i move the mouse just a tiny bit
enter image description here

Maybe it has something to do with the active window?, maybe when the game loads the window (since it is windowed) is not the active and so the mouse hide setting is not taking effect since now it only affects the cursor inside the game (because for instance i can see the original mouse in the title bar).

Any help will be very appreaciated. Also wanted to add that i don’t have a splash screen or loading. Thanks in advance :D.

P.D: Tried setting the mouse mode in each scene that uses the cursor individually and didn’t work either.

Try using Viewport and Input warp_mouse methods when game starts, maybe that could update the cursor too.

Or you can set a transparent image as custom cursor on project settings>display or with Input.set_custom_mouse_cursor.

eons | 2016-11-02 01:37

Hi @eons! thanks for the reply, i tried all three methods, forgot to mention i had already tried with Input.warp_mouse() to no avail, i testing with the display and setting a transparent custom cursor on project settings, didn’t work eiher.

No worries it’s not a big thing but i just thought it would look more profesional if the default windows cursor never shows hehe.

I’m still puzzled if it has something to do with the “active window” in Windows because when i click even if i don’t move it it’s fixed is like its not focused when the game launches. Happens the same from the debugger and exported proyect but no biggish, thanks for the tips, if you think of another option i would be glad to give it a try :-). I’m really out of ideas lol.

two_headed_goblin | 2016-11-02 02:18

There seems to be some bugs related to that (custom cursors and visibility), is supposed to be fixed by 3.0.

A hacky solution could be to warp the cursor outside the window, so the player is forced to move it at least once ^_^;

eons | 2016-11-02 17:28

Hehehehe that could be an option, not bad. Awesome thanks for the heads up regarding the 3.0 i’ll keep my ears open for that one.

two_headed_goblin | 2016-11-02 17:48