If I have multiple enemies attacking the player, then the player dies, how do I notify all the enemies that the player has died, and they no longer need to keep attacking? Enemies and the player are separate game objects.
I guess I could check every X frames to see if the player is dead, then I'd need to make sure the player doesn't respawn in that time. Unless I keep a "life number" value on the player.
Is there something I could do like having a "combat target" game object, which is destroyed and created new on death, so in my enemy scripts I could simply check if the target still exists?
What about some sort of event listener / subscriber system? So the player keeps a list of all enemies that are interested in hearing when he dies, then on death, sends a message to all of them? Unity doesn't have any of this sort of thing built in, right?
(sorry if this belongs on the forums, I couldnt decide whether this was best here or there!)