Create a gist now

Instantly share code, notes, and snippets.

anonymous /EnemyMob.cs
Created Jul 20, 2017

What would you like to do?
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