Question by 
               bichakhchyan · Oct 16, 2020 at 12:35 PM · 
                c#animationunity 52d  
              
 
              Enemy death animation keeps looping (Unity 2D)
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 - https://www.youtube.com/watch?v=sPiVz1k-fEs
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
               Comment
              
 
               
              Answer by dantefabian · Nov 02, 2020 at 10:07 AM
Go to Project Folder. Click on the Anim file you created for Death Animation. On the Inspector on the right uncheck Loop Time.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                