Godot Version
4.3
Question
In my latest game I’m making, you’re in a ship blasting enemies, and when you hit them, they flash red. However, the other enemy flashes red too, even though I didn’t hit him. So I’m at a loss as to make it so that only the enemy that gets hit plays the animation.
Here is the enemy code:
if hit:
HP -= 10
animation_player.play("Hit")
hit = false
Here is the bullet:
if body.is_in_group("enemy"):
if not body.invicible:
body.hit = true
queue_free()
Here’s how the enemy spawner spawns the enemy:
var instance = enemy.instantiate()
add_child.call_deferred(instance)