Advertisement
Eonirr

Untitled

May 2nd, 2023
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. private void Start()
  2. {
  3. player = GameObject.FindGameObjectWithTag("Player");
  4.  
  5. StartCoroutine(SpawnThem());
  6. }
  7.  
  8. IEnumerator SpawnThem()
  9. {
  10. for (int i = 0; i < maxCudeToSpawn; i++)
  11. {
  12. Vector2 spawnPosition = player.transform.position;
  13.  
  14. spawnPosition.x = spawnPosition.x + Random.Range(-5, 5);
  15. spawnPosition.y = spawnPosition.y + Random.Range(1, distanceToPlayer);
  16.  
  17. Instantiate(cubeToSpawn, spawnPosition, Quaternion.identity);
  18.  
  19. yield return new WaitForSeconds(timeToSpawn);
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement