Killing one enemy kill all enemy

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By pysaundary

the bullet which kill all zombie
func _on_bullet_area_entered(area):
extends Area2D

func _on_Zombie_body_entered(body):

func kill_the_zombie():

what i did :
i make one level scene in which i take one node of zombie which have 20+ instance node of zombie scene

and every bullet will generate using preload() and instance() when i press space key

the problem is that when i shoot single zombie all zombie disappear please help me .

Thanks in advance

:bust_in_silhouette: Reply From: timothybrentwood

the call_group is making it so every zombie is calling kill_the_zombie() on itself. You are passed in an area upon collision so you should use that to detect which zombie the bullet hit:
func on_bullet_area_entered(area):
    for zed in get_tree().get_nodes_in_group("zombie"):
        if zed == area:

Thankyou , i am very new in
game development and even programming

pysaundary | 2021-04-28 05:42