Controllers selecting buttons in UI

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

I’ve been trying to add full controller support to my game, and I think that in order to navigate the menus I first need to set up the grab_focus() stuff but my game will black screen whenever I pause or die with this code enabled. Any tips? Following is from the death screen.

func _ready():
	$Menu/PlayButton.grab_focus() 
	if Input.is_action_pressed("ui_focus_next"):
		 $Menu/ChangeSceneButton.grab_focus()
	elif $Menu/ChangeSceneButton.grab_focus() == true:
		$Menu/QuitButton.grab_focus()

I’m pretty sure this is not the problem.
Please show the code that pauses the game.

whiteshampoo | 2021-01-25 12:53

Here it is

 onready var scene_tree: = get_tree()
onready var pause_overlay: ColorRect= get_node("PauseOverlay")
var paused: = false setget set_paused

func _ready():
	pause_overlay.visible = false
	
	

func _unhandled_input(event:InputEvent)-> void:
	if event.is_action_pressed("pause"):
		self.paused = not paused
		scene_tree.set_input_as_handled()
		
	

func set_paused(value: bool) -> void:
	paused = value
	scene_tree.paused = value
	pause_overlay.visible = value

BuddyGames | 2021-01-25 14:14

is the pause_mode of your pause_overlay set to “process”?

whiteshampoo | 2021-01-25 14:21

Yup, it is set to process.

BuddyGames | 2021-01-25 21:12

Can you share your project folder?

whiteshampoo | 2021-01-26 07:40