- Edited
Hello everyone! That's magic to me:
I got 3 scenes, Main, Player and HUD
Inside player, I have a signal when the score should change and when we lost hp, then it down.
Afterthat this signals come to Main where this script reffers to HUD and changes helthbar and score.
The magic is- this completely similar signals and lines of code, but first works well, but second is broken and gave error.
Invalid call. Nonexistent function 'update_life' in base 'Nil'.
onready var hud = $HUD
func _on_enemy_died(_score):
score += _score
hud.update_score(score)
func _player_took_damage(_val):
hud.update_life(_val)
To make it work, I changed path to direct way, like this:
func _player_took_damage(_val):
$HUD.update_life(_val)
Error disappeared, but I still don't understand, how it works??