Hello,
In my game, I have a node called Pet in which I want the Player to catch. When the Player does, I have an event method called in the Pet node's script, where it would delete the Pet instance. However, I also want to call the HUD node's method to determine which of the HUD's labels should be updated.
With the code below, the HUD's _is_capacity_full() is called but always returns false even though it should return true when I run my game. I'm not sure if I had gotten the HUD script correctly and if it may be the problem...
signal pet_collected
signal pet_fallen
onready var hud = load("res://Scripts/HUD.gd")
func _on_Pet_body_entered(body):
if not hud._is_capacity_full():
print("Pet has reached Player")
emit_signal("pet_collected") # would update the HUD's Label1
queue_free() # deletes the Pet instance
else:
emit_signal("pet_fallen") # would update the HUD's Label2
queue_free()
Thank you in advance!
Edit:
I found in the debug log this error: Can't call non-static function '_is_capacity_full' in script.
So I tried to make that function static but it causes another error saying it can't access the HUD member variable in the static function. Is there a way to resolve that issue?