Godot Version
4.3 stable
Question
Hello I’m working on a simple action game and when the sword object object on my player collides with an object inside group (“enemy”) it delays the code execution until a collision happens with the most recently created object and then executes the code of all the instances at once. This is true regardless of whether I duplicate the enemies in the editor or I use a spawner to create them one at a time.
The enemy is a rigidbody in group “enemy” with a collision shape 2d. I’ve tried setting it to local to the scene. I’ve tried setting the group from local to global to no effect.
The sword object is an area2D with a small collision shape 2D which is child to the player object. It rotates, translates and flips when the player attacks.
The code which is being delayed on all but the recent-most instance is simple :
func _on_sword_area_body_entered(body: Node2D) → void:
print(“hit”)
if body.is_in_group(“enemy”) && attack_cdown < 0:
body._gets_hit()
I’m new to Godot and I’m discovering that it takes issue with many of the habits I’ve picked up in Unity so I assume I’m misunderstanding something fundamental about the way Godot handles hierarchy and collisions. Any ideas or requests for clarification are welcome.
Thanks!