Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RockSpawner : MonoBehaviour
- {
- public float spawnRate = 2;
- private float timer = 0;
- public float heightOffset = 10;
- public GameObject asteroid;
- public GameObject logic;
- public float bossTime = 12;
- public float modSpawnRate = 2;
- // Start is called before the first frame update
- void Start()
- {
- spawnAsteroid();
- }
- // Update is called once per frame
- void Update()
- {
- if (timer < modSpawnRate)
- {
- timer = timer + Time.deltaTime;
- }
- else
- {
- spawnAsteroid();
- timer = 0;
- bossTime = logic.GetComponent<bossTime>();
- modSpawnRate = (spawnRate + Random.Range(0,4) + bossTime);
- }
- }
- void spawnAsteroid()
- {
- float lowestPoint = transform.position.y - heightOffset;
- float highestPoint = transform.position.y + heightOffset;
- Instantiate(asteroid, new Vector3(transform.position.x, Random.Range(lowestPoint, highestPoint), 0), transform.rotation);
- }
- }
Add Comment
Please, Sign In to add comment