Godot 2D - Adding Path Enemy - Not adding to score

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)

func _on_enemy_died():
	score += 100

func _on_enemy_spawner_path_enemy_spawned(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():

func spawn_path_enemy():
	var path_enemy_instance = path_enemy_scene.instantiate()
	emit_signal("path_enemy_spawned", path_enemy_instance)
1 Like

Ignore this - as soon as I posted it I found my error. I would close this if I could. My connects are different. I called the original enemy_died but referenced died in the path enemy.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

glad you found the issue and your back on track :slight_smile:

Privacy & Terms