Created
October 8, 2015 15:28
-
-
Save ygjb/3095332b2107bc6489eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
void ClearField() | |
{ | |
GameObject[] targets = GameObject.FindGameObjectsWithTag("Target"); | |
foreach (GameObject target in targets) | |
{ | |
target.GetComponent<TargetExit>().Exit(); | |
} | |
} |
This file contains hidden or 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
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