To my understanding when calling is_in_group()
from the spawn function it returns true but when you call it from _on_Range_body_entered
it returns false?
If you have any kinematicBodies in your game that aren't Enemies then _on_Range_body_entered
could be detecting those instead which could be why is_in_group
is printing false. To check if this is the case call print(body.name)
after you check for the group to see if it really is an enemy (make sure to rename your Enemy node so the name doesn't come up as something generic such as KinematicBody2D)
print(body.get_groups())
is also useful for debugging. You can call it every frame in your enemy script to see if the group is somehow being removed (which I doubt), or you can call it in _on_Range_body_entered
to see what the detected object really is.
If your Area2D isn't detecting the Enemies at all one cause for this could be if you changed the Enemy's CollisionLayer to be different from the Area's CollisionMask.