# Animation for some reason doesn't trigger after death

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;

[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);
}
}
}


• Will the script looks fine to me and I am not sure about the solution to the problem but I am just guessing that have you checked the "time scale" if the scale is 0 then animator won't work. also, make sure that the trigger is assigned to transition. Mar 17 '20 at 11:40
• Sorry but where is time scale? I just got started in Unity 2 weeks ago, so I am still kinda noob. Also, the trigger is assigned to the transition, so I am not sure why it isn't working.
– user136618
Mar 17 '20 at 12:06
• Sorry for the delay... I hope you found a solution to your problem. But from time scale I mean "The scale at which time passes. This can be used for slow-motion effects or pausing games etc.". For more information, please visit the link. docs.unity3d.com/ScriptReference/Time-timeScale.html Mar 18 '20 at 5:25
• pretty sure I didn't mess with the time scale. I didn't have the word: Time.timeScale in any of my scripts so...
– user136618
Mar 18 '20 at 9:39
• Humm... seems strange... Then try to debug inside "if (stats.curHealth <= 0) { Debug.Log("Dead") } and check if compiler reaches there or not if not then its means that condition is not getting true so there is a problem with damage and if you see debug message then its means that there is a problem with the animator so then I guess we have to investigate animator further. Mar 18 '20 at 10:39