Scoring and Enemy Died Signal - Can't spawn enemies anymore

Hi folks, I think this time I’m stumped with what I did here. I tried to recreate what was done in this lesson to a mini game I’m making and I’m now not able to spawn enemies. I am getting errors when enemies are meant to appear however no enemies appear. The error is as below:

E 0:00:03:0343   enemy_spawner.gd:16 @ _spawn_enemy(): Can't emit non-existing signal "enemy_spawned".
  <C++ Error>    Condition "!signal_is_valid && !script.is_null() && !Ref<Script>(script)->has_script_signal(p_name)" is true. Returning: ERR_UNAVAILABLE
  <C++ Source>   core/object/object.cpp:1009 @ emit_signalp()
  <Stack Trace>  enemy_spawner.gd:16 @ _spawn_enemy()
                 enemy_spawner.gd:9 @ _on_timer_timeout()

And the code is as follows for enemy_spawner.gd:

extends Node2D

var lives = 3
var score = 0
@onready var player = $Player

func _on_death_zone_area_entered(area):
	area._die()

func _on_player_took_damage():
	lives -= 1
	if (lives == 0):
		print("Game Over")
		player.die()
	else:
		print(lives)

func _on_enemy_spawner_ememy_spawned(enemy_instance):
	enemy_instance.connect("died", _on_enemy_died)
	add_child(enemy_instance)
	
func _on_enemy_died():
	score += 100
	print("Score: "+str(score))

Hi,

that looks like your game.gd script. instead of the enemy_spawner.gd.

if you could pop up the enemy spawner for a look please.

would be worth ensuring you are declaring the signal at the top of the spawner script.

signal enemy_spawned(enemy_instance)
signal path_enemy_spawned(path_enemy_instance)

Hi apologies, that was a draft post I had a while back. Sorry for the confusion. I’ll delete the post.

1 Like

No worries :slight_smile:

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

Privacy & Terms