I have four scenes Player(KinematicBody2D), Enemy(KinematicBody2D), EnemySpawner(Position2D) and Level1(Node2D). I have instanced Player and EnemySpawner into Level1 and a timer time outs then the EnemySpawner instances a Enemy. And when my enemy hits player, the player loses some health but the first instance of enemy is working properly, second or third or fourth enemy instance are not dealing damage.
EnemySpawner code:
func spawn_enemy():
if !spawner_disabled:
var enemy_instance = enemy.instance()
enemy_instance.position = spawning_pos.global_position
get_tree().get_root().call_deferred("add_child", enemy_instance)
emit_signal("enemy_spawned")
func _on_Level1_spawn_enemy() -> void:
spawn_enemy()
Player code:
func _on_Hitbox_body_entered(body: Node) -> void:
if body.name == "Enemy":
damage_player(10)