I'm fairly new to Godot and so for my first real project I'm working on a tower defense game. I've run into a bit of a snag though, I'm trying to use a signal to update the health of your "crystal" when an enemy reaches it but the signal can't seem to find the function I've connected it to in my ui.
In my crystal script I've got two functions:
onready var health_bar = get_node("/root/Main/CanvasLayer/GUI/HBoxContainer/Bars/LifeBar")
signal crystal_damaged
func _ready():
connect("crystal_damaged", health_bar, "_on_crystal_damaged")
func hurt(value):
hp -= value
emit_signal("crystal_damaged", hp)
And in my LifeBar script I've got:
func _on_crystal_damaged(new_hp):
--snip--
The connect call seems to work (returns 0) but then when I try to run emit_signal, I get Error calling method from signal 'crystal_damaged': 'HBoxContainer::_on_crystal_damaged': Method not found.
I've already checked that the get_node at the top works, the signal name is the same in all three places and the function name matches between scripts (I even copied it directly just to be sure) but still no luck.
Unfortunately I have to do this through scripting since I'm adding the crystal through scripting.
I'm at a total loss here, is this a bug or am I missing something really obvious?