// Update is called once per frame void Update() { if (Time.time > nextTimeToSpawn) { secondsBetweenSpawns = Mathf.Lerp(secondsBetweenSpawnsMinMax.y, secondsBetweenSpawnsMinMax.x, Defecult.GetDifficultyPercent()); nextTimeToSpawn = Time.time + secondsBetweenSpawns; float scaleRandom = Random.Range(scaleMaxMin.x, scaleMaxMin.y); Vector2 spawnedPosition = new Vector2(Random.Range(screenHalfWidthAndHeight.x, -screenHalfWidthAndHeight.x), screenHalfWidthAndHeight.y + scaleRandom); GameObject newObject = (GameObject)Instantiate(objectToSpawn, spawnedPosition, Quaternion.Euler(0, 0, Random.Range(-rotationMax, rotationMax))); newObject.transform.parent = transform; newObject.transform.localScale = Vector3.one * scaleRandom; } }
private void Start() { speed = Mathf.Lerp(speedMinMax.x, speedMinMax.y, Defecult.GetDifficultyPercent()); visiblHightThreshold = -Camera.main.orthographicSize - transform.localScale.y; }