Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | echarette |
This is a 2D Platformer game which features an NPC you can interact with. He opens up a shop screen when interacted with. The shop screen consists of five buttons. One of them is a Leave shop button, three are upgrades, and one is a continue on (Because choosing this will allow passage to progress).
My issue here is I need full controller support and for some reason I can’t grab focus of the “Leave” button when the shop opens (that is, when I make the shop screen visible to the player).
The NPC is a KinematicBody 2D, and it has a child node that is a CanvasLayer, with the buttons being children of that. Here’s my script any help would be very appreciated!
Here’s some of the relevant script:
extends KinematicBody2D
var in_area = false
var open = false
onready var anim = get_node(“AnimationPlayer”)
signal purchase
func _ready():
pause_mode = PAUSE_MODE_PROCESS
$ShopScreen/Bubble.visible = false
func _process(delta):
if in_area:
if Input.is_action_just_pressed(“interact”):
if not open:
open_shop()
elif open:
close_shop()
func open_shop():
open = true
anim.play(“open”)
get_tree().paused = true
#$ShopScreen/Leave.grab_focus()
# I NEED TO GRAB FOCUS HERE BUT ITS NOT WORKING