public void findTarget() { var objects = Physics.OverlapSphere(character.transform.position, character.beliefs.sightRadius); foreach (var colliderObject in objects) { var cControl = colliderObject.gameObject.GetComponent <AbstractCharacterControl>(); if (cControl == null) { continue; } if (!character.isCharacterEnemy(cControl) || !isVisible(cControl.gameObject, sightRadius)) { continue; } target = cControl.gameObject; break; } }