Advertisement
jahedev

Untitled

Mar 28th, 2022
1,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Spawner : MonoBehaviour
  6. {
  7.     const int NUM_COINS = 10;
  8.     [SerializeField] GameObject coin;
  9.  
  10.     // Start is called before the first frame update
  11.     void Start()
  12.     {
  13.         Spawn();
  14.        
  15.     }
  16.  
  17.     // Update is called once per frame
  18.     void Update()
  19.     {
  20.        
  21.     }
  22.  
  23.     void Spawn()
  24.     {
  25.    
  26.         int xMin = -21;
  27.         int xMax = 0;
  28.         int yMin = 0;
  29.         int yMax = 8;
  30.  
  31.         for (int i = 0; i < NUM_COINS; i++)
  32.         {
  33.             Vector2 position = new Vector2(Random.Range(xMin, xMax), Random.Range(yMin, yMax));
  34.             Instantiate(coin, position, Quaternion.identity);
  35.         }
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement