Mouse cursor not dissapering

Godot Version

latest version

Question

when i type my code and then run the game my cursor isnt dissapering. can soemone help me?

thanks

func _ready():
   input.set_mouse_mode(input.MOUSE_MODE_HIDDEN)

Capitalization matters.

func _ready() -> void:
	Input.mouse_mode = Input.MOUSE_MODE_CAPTURED

Also, you can use set_mouse_mode(), but the correct way to do it is through assignment.

5 Likes

Is that gdscript?

Yes their post is in GDScript

Guys it’s still not working I have some screenshot this time

The first one is me running the game (and the mouse is not disappearing)

And the second one is the code I used

Instead of doing:

Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

You should do:

Input.mouse_mode = Input.MOUSE_MODE_CAPTURED

Like @dragonforge-dev said.

1 Like

Ok ill try it and tell you if it dosent work

1 Like

Capturing on _ready() may fail too, I’d recommend capturing the mouse when clicking

func _unhandled_input(event: InputEvent) -> void:
    if event is InputEventMouseButton:
        Input.mouse_mode = Input.MOUSE_MODE_CAPTURED

Make sure to paste code instead of screenshots.

1 Like

what node should i put all this code in?

Any node that exists in your scene; I suppose the player should be in control of mouse locking, or maybe a hidden pause menu? Maybe you can share your scene tree, make sure this script is actually attached to a node.

HALALUGUA I GOT IT TO WORK (sentence)

1 Like