public void reactToHit() { StartCoroutine(Die()); FollowingEnemy behavior = GetComponent <FollowingEnemy> (); if (behavior != null) { behavior.kill(); } Destroy(this.gameObject); }
private IEnumerator Die() { FollowingEnemy behavior = GetComponent <FollowingEnemy> (); if (behavior != null) { behavior.kill(); } this.transform.Rotate(-90, 0, 0); yield return(new WaitForSeconds(1.5f)); Destroy(this.gameObject); }