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