So I’m following along with the course and I seem too have hit a brick wall with the Score Ii not updating.
I have double that my scripts are correctly attached…
My hud.gd is attached to my Hud node (control node)
the script is he same as the lecture.
extends Control
@onready var score = $Score
func set_score_label(new_score):
score.text = "SCORE: " + str(new_score)
In the game scene. the game.gd is attached to the Gane(root node). and the code for the score Ui is the same as in the lecture.
extends Node2D
var lives = 3
var score = 0
@onready var player = $Player
@onready var hud = $UI/Hud
func _ready() -> void:
hud.set_score_label(score)
func _on_death_zone_area_entered(area: Area2D) -> void:
area.enemy_die()
func _on_player_took_damage():
lives -= 1
if lives == 0:
player.player_die()
func _on_enemy_spawner_enemy_spawned(new_enemy) -> void:
new_enemy.connect("enemy_died", _on_enemy_died)
add_child(new_enemy)
func _on_enemy_died():
score += 100
hud.set_score_label(score)
But my score does not update when the enemy dies
Did I miss something?
I am not sure if this is relevant , but im using Godot 1.2.1