I have a player and a few enemies. When the player shoots and the bullet collides with the enemy, I want to play a hit animation on the enemy.
Simplified code:
func _on_shot_body_enter(body):
print("shot enemy", body)
body.hp=body.hp-1
body.get_node("body/anim").play("hit")
The collision part works, and the individual hit points work. However; ALL of the enemy instances play the hit animation, not the specific individual instance that was hit. In the Output I get: shot enemy[KinematicBody2D:605]
I tried a few different tactics, even using a hit function and calling
self.get_child(0).get_child(0).play("hit")
but still have all enemies trigger. I suspect it is because of the get_node part, but I am not sure how to trigger only the instance hit's AnimationPlayer.