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():
pausemode = PAUSEMODEPROCESS
$ShopScreen/Bubble.visible = false
func process(delta):
if inarea:
if Input.isactionjustpressed("interact"):
if not open:
openshop()
elif open:
close_shop()
func openshop():
open = true
anim.play("open")
gettree().paused = true
#$ShopScreen/Leave.grab_focus()
# I NEED TO GRAB FOCUS HERE BUT ITS NOT WORKING