Area_entered can detect objects in some groups, but not others

Godot Version

4.2.2 stable Windows 11

Question

In my player node, I have this code to detect whether an enemy or bullet is within the player’s hurtbox:

func _on_hurtbox_area_entered(other):
	if other.is_in_group("enemattack") or other.is_in_group("bullet"):
		if not other.get("damage") == null:
			collision.call_deferred("set", "disabled", true)
			iframes.start()
			hurt(other.get("damage"))
			print("you're taking damage!")

This works perfectly when an enemy (whose hitbox Area2D is in group “enemattack”) enters the hurtbox, but does nothing when a bullet (whose hitbox Area2D is in group “bullet”) enters the hurtbox. I’ve made sure the bullet’s damage value is not null.

Furthermore, I also have this code, in my player script as well:

func _on_interact_area_area_entered(area):
	if area.is_in_group("sugar"):
		area.target = self
		print("grab that sugar!")

func _on_collect_area_area_entered(area):
	if area.is_in_group("sugar"):
		sugar_held += area.collect()
		print("sugar increased!")

This is to check if objects in the group “sugar” are nearby, and to collect and increase sugar_held if they are even closer. But nothing happens, nothing even gets printed.

This is what my player scene tree looks like:
image

What’s the problem here? Why do objects in the group “enemattack” get detected by the player, but objects in the other groups don’t? Any help is appreciated.

you sure it enters the area? because bullet can be so fast it teleported behind the hurtbox area2d

The bullets I’m testing are slower than the player, and the “sugar” objects are static.

if you enabled the collision debug shape, can you confirm the bullet area intersects with the player hurtbox?
image

Correct, the bullet area intersects with the player hurtbox, and the sugar area also intersects with the player’s other two areas.

and your area layer and masking is correct?

Yep. Player hurtbox is layer 2 mask 3 & 5, enemy hitbox is layer 3 mask 2, and bullet is layer 5 mask 2.

I checked the layers for sugar and the player interaction and collect areas, and they were indeed wrong, so I changed them and that made it work. Bullets are still not working though…