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

I have a problem: I made a bullet, added as a child node, when you press space bullet is being added as a child, point is to shoot asteroids which split in half, i set asteroids to react
if area.get_name =="bullet" but then the problem is that only the first bullet is named "bullet" other ones when generated are named like @bullet@34 etc. how should I make asteroids react to every bullet, what should I do???

in Engine by (47 points)

1 Answer

+2 votes
Best answer

Names must be unique among sibling nodes.

For a situation like this, groups are an ideal solution. Put your bullet in a group called "bullets", and then you can do

if area.is_in_group("bullets"):

Another solution is to use

class_name Bullet

in the top of the bullet's script and then you can do

if area is Bullet:
by (22,191 points)
selected by
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.