#What will be the best way to disable user input
5 messages · Page 1 of 1 (latest)
you can stop any of the processes using set_process(false), set_input_process(false), etc
you can also have a variable holding the game state and just just the input logic if certain state is current
A common way is to have a "is_paused" boolean variable in an autoloaded script, and then in your process function you simply don't handle any input if that variable is true. Useful to also pause enemies, bullets, etc
i have a signal bus set up and use a pause signal, that calls a function that does
get_tree().paused = true
It also hides some UI elements and sets a global variable that is checked in a few places where the node is set to always process. though thats a bit hacky, i should just be checking the .paused
I then have a bunch of UI elements set to "Always" process, so that they run while the game is paused.
Lets me still use inputs and processing where i want it, and whenever i need to have the game pause somewhere else in my code i just connect to the signal bus and send a pause signal
I have a similar arrangement for resuming the game