void Update() { // TODO: change this to fire CheckTask on trigger enter or something... if (movingToPlatform) { if (!agent.pathPending) { if (agent.remainingDistance <= agent.stoppingDistance) { if (!agent.hasPath || agent.velocity.sqrMagnitude == 0f) { Debug.Log("ARRIVED>>>>>"); movingToPlatform = false; CheckTask(); } } } } // Archers scanning for enemies // can continuously check if enemy is attacking, but for performance and gameplay, might want to handicap this, put it in a coroutine or something if (occupation == 4) { Collider2D enemyInRange = Physics2D.OverlapCircle(transform.position, collider.radius, enemyLayer); if (enemyInRange != null) { if (!kingScript.enemySighted) { kingScript.AlertArchers(enemyInRange); } if (!firing) { firing = true; StartCoroutine(FireProjectile()); } } } }