Path enemy not adding to score

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

func _on_body_entered(body):

Game Script:

func _on_enemy_died():
	score += 100

func _on_enemy_spawner_path_enemy_spawned(path_enemy_instance):
	path_enemy_instance.connect("died", _on_enemy_died)

Path_Enemy Script

extends Path2D

@onready var pathfollow = $PathFollow2D
@onready var enemy = $PathFollow2D/Enemy2

func _ready():

func _process(delta):
	pathfollow.progress_ratio -= 0.25 * delta
	if pathfollow.progress_ratio<=0:

Any help is appreciate as I’m stuck on this one.

I think I see what’s happening here. I might have even run into exactly this problem when I did this project!

When you spawn a path enemy currently, you are trying to connect path enemy’s died signal to on_enemy_died, but it doesn’t belong to the path enemy; it belongs to Enemy2. I checked this on my own project, and I did indeed have to access instance.enemy to connect the signal:


Give that a try and let’s see if that fixes it =)

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

Privacy & Terms