|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
dany_pitre |
Hi ! I’ve been trying to make a loot that kills all the enemy in the scene when touched and i cant figure out how.
All my enemies are spawning from a spawner. they are all kinematicbodies2d.
Someone has some ideas or queue lines …?
Thanks a lot !
|
|
|
 |
Reply From: |
timothybrentwood |
When you are instance()
-ing and add_child()
-ing your enemies also:
var new_enemy = enemy_scene.instance()
self.add_child(new_enemy)
new_enemy.add_to_group("enemies")
Then when you pick up that item you can:
for enemy in get_tree().get_nodes_in_group("enemies"):
enemy.die()
alternatively:
get_tree().call_group("enemies", "die")
Replace die
with whatever function you use to kill your enemies normally.
Thank you so much, it works and I learned the concept of group !
dany_pitre | 2021-05-06 23:53