Pause Menu Mouse

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DerpyCoder

So im starting in game development and i was trying to make a pause menu, but there is one problem. You see im making a 3D game and i want the cursor to be hidden when im not in the pause menu, but every video i watch, they are making a 2D game. Ill post the code at the end, Any help i can get?

extends Control

func _input(event):
if event.is_action_pressed(“ui_cancel”):
var new_pause_state = not get_tree().paused
get_tree().paused = not get_tree().paused
visible = new_pause_state

:bust_in_silhouette: Reply From: Gluon

You can use

MOUSE_MODE_VISIBLE = 0 -– Makes the mouse cursor visible if it is hidden.

MOUSE_MODE_HIDDEN = 1 — Makes the mouse cursor hidden if it is visible.

just change it as appropriate when you pause or unpause in your code.

Send me a code using this please, i cant use this, where do i put it? How

Also, Can you explain me this entire code?
I didnt understand its so confusing
get_tree paused = not get_tree paused ???

When i press the menu button and play again, the game is still paused