Name Problem

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

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

:bust_in_silhouette: Reply From: kidscancode

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: