private void ApplySwordDamage() //Invoked as Animation Event { if (MathHelper.CalculateDistance(transform.position, _player.transform.position) <= 2.5 * 2.5) //TODO try to refactor this { _playerHealth.TakeDamage(damage, null); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("AttackMouse0")) { enemyHealthBarScript.Damaged(); } if (other.CompareTag("Player")) { playerHealth.TakeDamage(); } }
void Attack() { // Reset the timer. timer = 0f; // If the player has health to lose... if (playerHealth.currentHealth > 0) { // ... damage the player. playerHealth.TakeDamage(attackdmg); } }
void OnTriggerEnter(Collider other) { // // If the entering collider is the player... if (other.gameObject == GameObject.FindGameObjectWithTag("Player")) { if (playerHealth.currentHealth > 0) { // ... damage the player. playerHealth.TakeDamage(attackdmg); } // ... the player is in range. // playerInRange = true; } }
public void DamageToThePlayer(Templar templarScript) { playerCaracteristics.playerHealth -= templarScript.templarDamage; if (playerCaracteristics.playerHealth > 0) { animator.SetTrigger("playerIsHit"); Debug.Log("Damage to the playeeer FUsckjklj !!!!"); Debug.Log(playerCaracteristics.playerHealth); healthPlayerScript.TakeDamage(); } else if (playerCaracteristics.playerHealth <= 0) { animator.SetTrigger("playerIsDead"); } }