// Generate units if stationed units is less than genMax void Update() { if (tower.StationedUnits < genMax) { genTimer += Time.deltaTime; float spawnInterval = 1f / UnitsProducedPerSecond; // Calculate interval. Eventualy will be a constant. if (genTimer >= spawnInterval) { tower.IncStationedUnits(); TotalProduced++; genTimer = 0; } } }