Created
July 20, 2017 21:01
-
-
Save anonymous/29f7171737db1cb7f4e1034fa1e45ec1 to your computer and use it in GitHub Desktop.
Enemy Mob script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Method activated when Simple2DTargetScanner OnTargetHit event is called. | |
void OnTargetHit(Transform target) | |
{ | |
//do something with target hit | |
} | |
void OnEnable() | |
{ | |
//subscribe to Simple2DTargetScanner OnTargetHit event notification if GameObject is enabled. | |
this.transform.GetComponent<Simple2DTargetScanner>().OnTargetHit += OnTargetHit; | |
} | |
void OnDisable() | |
{ | |
//unsubscribe to Simple2DTargetScanner OnTargetHit event notification if GameObject is disabled | |
this.transform.GetComponent<Simple2DTargetScanner>().OnTargetHit -= OnTargetHit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment