using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; public class EnemyAnimationHandler : MonoBehaviour { Animator animator; bool isDying = false; void Start() { animator = GetComponent(); if (animator != animator.enabled) animator.enabled = true; GetComponentInParent().OnHealthZero.AddListener(EnemyDie); } void EnemyDie() { //GetComponent().enabled = false; //GetComponent().enabled = false; if (!isDying) StartCoroutine(AnimationDie()); } IEnumerator AnimationDie() { isDying = true; Strangle(); Debug.Log("Strangle"); yield return new WaitForSecondsRealtime(0.1f); Die(); } public void Strangle() { animator.SetTrigger("Strangle"); } public void Die() { animator.SetTrigger("Die"); } public void DestroyGameobject() { Destroy(transform.parent.gameObject); } }