Advertisement
Guest User

Untitled

a guest
Apr 24th, 2024
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. public class RockSpawner : MonoBehaviour
  2. {
  3.     public float spawnRate = 2;
  4.     private float timer = 0;
  5.     public float heightOffset = 10;
  6.     public GameObject asteroid;
  7.     public GameObject logic;
  8.  
  9.     // Start is called before the first frame update
  10.     void Start()
  11.     {
  12.         spawnAsteroid();
  13.         public float boss = logic.GetComponent<bossTime>();
  14.     }
  15.  
  16.     // Update is called once per frame
  17.     void Update()
  18.     {
  19.         spawnRate = (spawnRate + boss);
  20.         if (timer < spawnRate)
  21.         {
  22.             timer = timer + Time.deltaTime;
  23.         }
  24.         else
  25.         {
  26.             spawnAsteroid();
  27.             timer = 0;
  28.         }
  29.     }
  30.  
  31.     void spawnAsteroid()
  32.     {
  33.         float lowestPoint = transform.position.y - heightOffset;
  34.         float highestPoint = transform.position.y + heightOffset;
  35.  
  36.         Instantiate(asteroid, new Vector3(transform.position.x, Random.Range(lowestPoint, highestPoint), 0), transform.rotation);
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement