Hi there,
I have followed the steps clearly and the code is identical however I am finding that my score is not increasing when I shot a path enemy.
func _on_enemy_spawner_enemy_spawned(enemy_instance):
enemy_instance.connect("enemy_died", _on_enemy_died)
add_child(enemy_instance)
func _on_enemy_died():
score += 100
hud.set_score_label(score)
enemy_hit_sound.play()
func _on_enemy_spawner_path_enemy_spawned(path_enemy_instance):
add_child(path_enemy_instance)
path_enemy_instance.enemy.connect("died", _on_enemy_died)
Here is my Enemy Spawner code:
extends Node2D
signal enemy_spawned(enemy_instance)
signal path_enemy_spawned(path_enemy_instance)
@onready var timer = $Timer
@onready var spawn_positions = $SpawnPostions
var enemy_scene = preload("res://scenes/enemy.tscn")
var path_enemy_scene = preload("res://scenes/path_enemy.tscn")
func _ready():
timer.connect("timeout", spawn_enemy)
func spawn_enemy():
var spawn_postions_array = spawn_positions.get_children()
var random_spawn_position = spawn_postions_array.pick_random()
var enemy_instance = enemy_scene.instantiate()
enemy_instance.global_position = random_spawn_position.global_position
emit_signal("enemy_spawned", enemy_instance)
func _on_path_timer_timeout():
spawn_path_enemy()
func spawn_path_enemy():
var path_enemy_instance = path_enemy_scene.instantiate()
emit_signal("path_enemy_spawned", path_enemy_instance)