// Update is called once per frame void Update() { if (isAttacking) { atkTimer += Time.deltaTime; shotTimer -= Time.deltaTime; } else { atkwait += Time.deltaTime; } if (atkwait > atkFrequency) { isAttacking = true; } if (atkTimer > shootingTime) { isAttacking = false; movement.idleOff(); atkTimer = 0; } if (movement.getDistanceToPlayer() < atkRange && inAttackMode) { movement.idleOn(); movement.lookAtPlayer(); attack(); } }