Skip to content

Instantly share code, notes, and snippets.

@ygjb ygjb/GameManager.cs
Created Oct 8, 2015

Embed
What would you like to do?
void ClearField()
{
GameObject[] targets = GameObject.FindGameObjectsWithTag("Target");
foreach (GameObject target in targets)
{
target.GetComponent<TargetExit>().Exit();
}
}
public void Exit()
{
if (this.GetComponent<Animator>() == null)
// no Animator so just destroy right away
KillTarget();
else if (!startDestroy)
{
// set startDestroy to true so this code will not run a second time
startDestroy = true;
// trigger the Animator to make the "Exit" transition
this.GetComponent<Animator>().SetTrigger("Exit");
// Call KillTarget function after exitAnimationSeconds to give time for animation to play
Invoke("KillTarget", exitAnimationSeconds);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.