void Update() { if (Time.time > nextSpawnTime) { //Linear Interpolation // a, b and move between them via percentage p //value = a + (b - a) * p float secondsBetweenSpawn = Mathf.Lerp( secondsBetweenSpawnMinMax.y, secondsBetweenSpawnMinMax.x, DifficultyInformation.GetDifficultyPercentage() ); nextSpawnTime = Time.time + secondsBetweenSpawn; float spawnAngle = Random.Range(-spawnAngleMax, spawnAngleMax); float spawnSize = Random.Range(spawnScaleMinMax.x, spawnScaleMinMax.y); Vector2 spawnPosition = new Vector2( Random.Range(-screenHalfSizeWorldUnits.x, screenHalfSizeWorldUnits.x), screenHalfSizeWorldUnits.y + spawnSize ); GameObject block = (GameObject)Instantiate(fallingBlockPrefab, spawnPosition, Quaternion.Euler(0, 0, spawnAngle)); block.transform.localScale = Vector3.one * spawnSize; } }
void Start() { speed = Mathf.Lerp( speedMinMax.x, speedMinMax.y, DifficultyInformation.GetDifficultyPercentage() ); visibleHeightThreshold = -Camera.main.orthographicSize - transform.localScale.y; }