I got a little too fancy by creating enemy2 and using the additional enemy image, and everything works, but the adding to the score.
Enemy2 Script:
extends Area2D
signal died
func die():
queue_free()
emit_signal("died")
func _on_body_entered(body):
body.take_damage()
die()
Game Script:
func _on_enemy_died():
enemy_hit_sound.play()
score += 100
hud.set_score_label(score)
func _on_enemy_spawner_path_enemy_spawned(path_enemy_instance):
path_enemy_instance.connect("died", _on_enemy_died)
add_child(path_enemy_instance)
Path_Enemy Script
extends Path2D
@onready var pathfollow = $PathFollow2D
@onready var enemy = $PathFollow2D/Enemy2
func _ready():
pathfollow.set_progress_ratio(1)
func _process(delta):
pathfollow.progress_ratio -= 0.25 * delta
if pathfollow.progress_ratio<=0:
queue_free()
Any help is appreciate as I’m stuck on this one.