Godot Version
4.3
Question
I’m a little at a loss here trying to get a held item to turn invisible once there are none left in the slot but no matter what I try it always returns null
extends Button
@onready var background_sprite: Sprite2D = $Background
@onready var item_stack_gui: ItemStackGUI = $CenterContainer/Panel
@onready var player = get_tree().root.find_child("Player")
func update_to_slot(slot: InventorySlot) -> void:
if !slot.item:
item_stack_gui.visible = false
background_sprite.frame = 0
player.hand_equip.visible = false
return
item_stack_gui.inventorySlot = slot
item_stack_gui.update()
item_stack_gui.visible = true
background_sprite.frame = 1
extends Node2D
var hand_equip : Node2D
func _ready():
if get_children().is_empty(): return
hand_equip = get_children()[0]
func add_hand_equip(new_hand_equip) -> void:
if hand_equip && hand_equip.name == new_hand_equip.name: return
if hand_equip:
remove_child(hand_equip)
hand_equip = new_hand_equip
add_child(new_hand_equip)
func remove_hand_equip() -> void:
remove_child(hand_equip)
hand_equip = null