// Update is called once per frame void Update() { if (playerController.attacking && canDamage) { frameCount++; if (frameCount == 2) { GameObject AttackedEnemy = LineCastCollision(out attackPosition); if (AttackedEnemy != null) { //hit AttackedEnemy.GetComponent <EnemyController>().GetHit(attackPosition); if (!AttackedEnemy.GetComponent <EnemyStates>().isAlive) { playerStates.ScoreAdd(); } canDamage = false; } frameCount = 0; } } if (!playerController.attacking) { canDamage = true; } }