When my character kills an enemy unit, its death animation keeps playing. I’m new to unity and I followed the Brackeys melee combat tutorial - MELEE COMBAT in Unity - YouTube
Everything seems right except this. Here is my “Enemy” code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour
{
public Animator anim;
public int maxHealth = 100;
int currentHealth;
public bool isDead = false;
// Start is called before the first frame update
void Start()
{
currentHealth = maxHealth;
}
public void TakeDamage(int damage)
{
currentHealth -= damage;
anim.SetTrigger("Hurt");
//Play hurt animation
if(currentHealth <= 0)
{
Die();
}
}
void Die()
{
anim.SetBool("isDead", true);
GetComponent<Collider2D>().enabled = false;
this.enabled = false;
}
}
Please let me know if you have any solutions to this problem.
Thanks in advance