added enemy dead animation
This commit is contained in:
@@ -7,19 +7,24 @@ namespace Darkmatter.Presentation
|
||||
{
|
||||
public float health = 100f;
|
||||
public Animator enemyAnimator;
|
||||
public bool isDead = false;
|
||||
public void Die()
|
||||
{
|
||||
isDead = true;
|
||||
Debug.Log("Dead");
|
||||
this.gameObject.SetActive(false);
|
||||
enemyAnimator.SetLayerWeight(0, 1);
|
||||
enemyAnimator.SetTrigger("Death");
|
||||
Destroy(this.gameObject, 5f);
|
||||
}
|
||||
|
||||
public void TakeDamage(float damage)
|
||||
{
|
||||
{ if(isDead) return;
|
||||
health -= damage;
|
||||
enemyAnimator.SetLayerWeight(1, 1);
|
||||
enemyAnimator.SetTrigger("Hit");
|
||||
if (health <= 0) Die();
|
||||
Debug.Log("Damage Taken");
|
||||
|
||||
enemyAnimator.SetLayerWeight(1, 1);
|
||||
enemyAnimator.SetTrigger("Hit");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user