protected void OnTriggerEnter2D(Collider2D collision) { if (collision.GetComponent <Collider2D>().CompareTag("Projectiles")) { healthPoint -= collision.gameObject.GetComponent <ProjectileScript>().AttackPower; StartCoroutine(anim.DamageAnimation()); if (healthPoint <= 0) { Destroy(gameObject); } } }
public void ReceivedDamage(float DamageTaken) //Function to damage the enemy { HP -= DamageTaken; if (HP <= 0) { //call death animation enemyAnimation.DeathAnimation(); gameObject.GetComponent <BoxCollider>().enabled = false; //disactivates enemies Destroy(Vision); Idle = false; Patrol = false; DetectedPlayer = false; HuntingPlayer = false; dead = true; Agent.isStopped = true; } //call damage animation DetectedPlayer = true; enemyAnimation.DamageAnimation(); }