private void DetermineOpponent() { //select opponent (priority is units over spawners) _opponent = null; //reset each loop _opponentDistanceSquared = float.MaxValue; if (TargetNonSpawnerEnemy != null && TargetNonSpawnerEnemy.GetHealth() > 0) //ClosestEnemyUnit { _opponent = TargetNonSpawnerEnemy; _opponentDistanceSquared = DistanceSquaredFromNearestEnemyUnit; } else { if (TargetSpawner != null && TargetSpawner.Health > 0) { _opponent = TargetSpawner; _opponentDistanceSquared = DistanceSquaredFromNearestEnemySpawner; } else //if no targets, why in this logic anyway? haha { return; } } if (_opponent != null) { //DEBUG if (TEXT_DEBUG_ENABLED) { TestDebugOutput = "Attack | " + _opponent.transform.name; } } }