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