I have enemies in my scene, and in "EnemyHealth" scritp have a method "TakeDamage". I want to use c# delegate/event in "PlayerAttack" script to damage the specifically enemy. But these same enemies(prefabs) all have "TakeDamage" method subscribed the delegate/event which in "PlayerAttack" script, once I fire the delegate/event, all the enemies will take damage.
So, how to send a message to a specifically target ?
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
3 People are following this question.
Delegates versus class references
Event to change level
Login form: Do I have to set custom delegates to null in OnDestroy?
Score system using events to pass data?
Delegate an event