void ScanUnits2() { foreach (GameObject unit in mSecondObjList) { mMovement = unit.GetComponent <MovementControlScript>(); mBlobProperties = unit.GetComponent <BlobProperties>(); mAttack = unit.GetComponent <AttackScript>(); //If the target is currently engaged, dont change their orders if (mAttack.GetEngage()) { return; } //Something is in attack range. Fight it if (mBlobProperties.GetEnemyInRange().Count > 0) { foreach (GameObject obj in mBlobProperties.GetEnemyInRange()) { if (obj.GetComponent <BasicUnitScript>().GetOwnerID() != unit.GetComponent <BasicUnitScript>().GetOwnerID()) { mAttack.SetAttackTarget(obj); mMovement.AttackUnit(obj); break; } } } else { mAttack.SetEngage(false); } } }