Hey! Is there a way to ignore any controller inputs if the window for the game isn’t focused? I know there are signals to check when the game is focused/off focus, but is there a way to do like, super pseudocode:
You can get signals for the window being focused; but you cannot quickly disable controller specific inputs, you may have to settle for pausing the game
I fear pausing the game wouldn’t work, since it’s an idle game, my players want to play other games on the side and my game captures input even if it’s unfocused.
Good news is there is a pull request with great traction adding just this feature as a simple project setting check box. Maybe 4.7 will have it; fingers crossed
You could add a global script to track window focusing, then ensure your actions/input functions are only run when the global focus is set. This could be a lot of work if you do have many controller objects, I think UI focus may still be affected too, unsure how to resolve that specifically, maybe release_focus()?
extends Node
var in_focus: bool = true
func _ready() -> void:
var window := get_window()
window.focus_entered.connect(_set_focus.bind(true))
window.focus_exited.connect(_set_focus.bind(false))
func _set_focus(new_focus: bool) -> void:
in_focus = new_focus
if new_focus == false:
var gui_focus: Control = get_window().gui_get_focus_owner()
if gui_focus:
gui_focus.release_focus()
As for your second message, the whole game is UI Buttons so it’s a bit complicated on that end haha. I’m just going to hope for the issue to get in! Thanks for the info!