Area 2D error 4.3

Godot 4.3

I made a projectile (ki blast) and added it into a group(enemy_killer). Now when the projectile hits the enemy, he doesnt die. I tested that if the area entered the enemy, print(area entered), but it doesnt work. Script:-

extends AnimatedSprite2D

func _on_hitbox_area_entered(area):
print(“in area”)
if area.is_in_group(“enemy_killer”):
print(“in group”)
area.get_parent().queue_free()
queue_free()

Have you checked your collision layers. Here is an example from one of mine:

image

Here you can see the player is in Layer 1 (which is named ‘Player’). All the mask layers are layers that it detects. If something is in layer 4, say, my player will not detect it.

It is also worth checking that your areas are either monitorable, monitoring or both. These are checkboxes in the inspector.

It might also be more useful to print the area itself like this:

print("Hitbox area entered: ", area)

You seem to imply that this was working before you added the group. So it is also worth double checking that your group name is the same as the one you are testing for: ‘enemy_killer’.

Hope that helps in some way.

1 Like

Okay so the projectile is in area, but it isnt printing “in group”, which means it isnt in the group. How can i fix this.

Try adding this after the in area print.

print(area.get_groups())

Then you can see what groups it is actually in.

1 Like

Thanks, you helped me twice.

1 Like