Skip to content

Instantly share code, notes, and snippets.

Created July 20, 2017 21:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/29f7171737db1cb7f4e1034fa1e45ec1 to your computer and use it in GitHub Desktop.
Enemy Mob script
//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