So I am trying to trigger this explosion animation after this enemy dies, but for some reason the animation doesn't trigger. I've made sure that the explosion animation is linked to "Any State", and that the transition from any state to the explosion animation has the trigger "Death". Here is my script (only the important parts):
using UnityEngine; using System.Collections; public class Enemy : MonoBehaviour { [System.Serializable] public class EnemyStats { public int maxHealth = 100; private int _curHealth; public int curHealth { get { return _curHealth; } set { _curHealth = Mathf.Clamp(value, 0, maxHealth); } } public void Init() { curHealth = maxHealth; } public int damage = 40; } public EnemyStats stats = new EnemyStats(); private Animator anim; [Header("Optional: ")] [SerializeField] private StatusIndicator statusIndicator; void Awake() { anim = transform.GetComponent<Animator>(); } public void DamageEnemy(int damage) { stats.curHealth -= damage; if (stats.curHealth <= 0) { GameMaster.KillEnemy(this); anim.SetTrigger("Death"); } if (statusIndicator != null) { statusIndicator.SetHealth(stats.curHealth, stats.maxHealth); } } public void OnCollisionEnter2D(Collision2D _colInfo) { Player _player = _colInfo.collider.GetComponent<Player>(); if (_player != null) { _player.DamagePlayer(stats.damage); DamageEnemy(999999999); } } } 








