0 votes

the bullet which kill all zombie

bullet.gd
func onbulletareaentered(area):
queuefree()
get
tree().callgroup("zombie","killthe_zombie")

zombie.gd
extends Area2D

func onZombiebodyentered(body):
gettree().callgroup("robothelooser","player_hurt")

func killthezombie():
queue_free()

................................................................
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

Godot version 3.3
in Engine by (19 points)

1 Answer

+1 vote
Best answer
get_tree().call_group("zombie","kill_the_zombie")

the callgroup is making it so every zombie is calling killthe_zombie() on itself. You are passed in an area upon collision so you should use that to detect which zombie the bullet hit:

bullet.gd
func on_bullet_area_entered(area):
    for zed in get_tree().get_nodes_in_group("zombie"):
        if zed == area:
            zed.kill_the_zombie()
    queue_free()
by (2,838 points)
selected by

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.