Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Start()
- {
- player = GameObject.FindGameObjectWithTag("Player");
- StartCoroutine(SpawnThem());
- }
- IEnumerator SpawnThem()
- {
- for (int i = 0; i < maxCudeToSpawn; i++)
- {
- Vector2 spawnPosition = player.transform.position;
- spawnPosition.x = spawnPosition.x + Random.Range(-5, 5);
- spawnPosition.y = spawnPosition.y + Random.Range(1, distanceToPlayer);
- Instantiate(cubeToSpawn, spawnPosition, Quaternion.identity);
- yield return new WaitForSeconds(timeToSpawn);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement