x


Notifying multiple enemies on player death

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!)

more ▼

asked Oct 03 '11 at 01:43 PM

mouseman919 gravatar image

mouseman919
1 7 8 8

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x166
x53
x27
x15
x8

asked: Oct 03 '11 at 01:43 PM

Seen: 530 times

Last Updated: Oct 03 '11 at 01:43 PM