This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hello Again Community :)
i've made space invaders game
i connected Aliens ((RigidBody2D)) with a timer in main node

when the player Die ((Area2d))
alien Timer stops and new aliens stop coming that's Good Until now

But Aliens Which are already in the game screen stays
and when i press new game i see the old aliens still on the screen
how i can remove Them !!!
(( aliens Node are instance child in the main node))
i tried a lot of functions to delete them but i've failed :(

in Engine by (118 points)
edited by

2 Answers

+1 vote
Best answer

Add all the aliens to a group. When the player dies, send a signal to the group. When the alien gets the signal, make it die.

So something like:

in the alien script _ready() function:


Add a function for the alien to react to the death of the player:

func player_dead() -> void:
      # make the alien gloat ;)

Then in your player script, when the player dies:

get_tree().call_group("alien", "player_dead")   
by (2,065 points)
selected by

Thank you so much... dude :)

+1 vote

Add aliens in group enemy and when the player dies run this code

var enemies = get_tree().get_nodes_in_group("enemy")
for i in enemies:
by (753 points)

Thank you So much I Will try it

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 Frequently asked questions and 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 [email protected] with your username.