I’m still very new to Godot and I know to how to set up a basic input event to turn the mouse mode from captured to uncaptured. But I was trying to make an actual pause menu to go along with it using some of my own code and some stuff from tutorials.
But for some reason my game is paused 100% of the time, the buttons don’t work, and the freeing of the mouse isn’t tied to whether or not the game is paused.
(What I mean by that is that even though the pause menu is up no matter what you do, in order to get the mouse visible you still have to press escape.)
My code and scene tree are attached, any help would be great, because I’m not a programmer.
You must set your pause menu to also process when paused. In the pausemenu’s Node properties set process mode to ‘Always’ or ‘When Paused’
I’ve seen this @onready var my_script = $"." thing often, where did you get that? It’s equivalent and slower than using self or the functions directly, for example these three lines are the same in your script, and you should prefer the last two
as for the onready variables, like I said I’m not a programmer I’m learning by watching tutorials and just trying stuff and just about every video I’ve seen that needs to control a node with code uses an onready variable, and one of them even made it sound like you have to do that to work with a node directly, and as I haven’t gotten deep into the documentation, I just assumed that was the truth.
Also, I tried both “always process” and “process when paused”, and “when paused” is the closest to working as intended. It got the quit button to work. And the game starts off with the player able to move the camera around, only behind the pause menu because it’s still there 100% of the time. Freeing the mouse works as expected but it doesn’t ever recapture, and the resume button still doesn’t work. (Probably because it’s trying to do the same thing the escape key is set to do, which also doesn’t work.)
And before you say, “Well if you’re learning from tutorials, why don’t you follow one?”. The videos that show you how to free the mouse don’t actually have it bring up a menu. And the pause menu tutorials I saw, one was for a game where the mouse was never captured so that wouldn’t work, and one just didn’t work when I followed it. So I just figured I’d use the small gdscript course I took and just figure it out, which led me here.
Aha! It is slower computationally (by a little bit) and coding wise I suppose, it’s much faster to simply not. I see why it keeps popping up, you do not have to drag the node into the editor if it’s the same node the script is attached to.
You will need to re-capture the mouse in code, when the pause menu is hidden also set the mouse mode to captured.
thank you for all your help, I don’t know how I never noticed I didn’t ever tell it to recapture the mouse or the fact that I was just calling a true/false vriable
I got it working properly, partly with your help and partly some other jank fixes, I’m sure it’s barely held together with duct tape but everything works.