Advertisement
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;
- // Start is called before the first frame update
- void Start()
- {
- spawnAsteroid();
- public float boss = logic.GetComponent<bossTime>();
- }
- // Update is called once per frame
- void Update()
- {
- spawnRate = (spawnRate + boss);
- if (timer < spawnRate)
- {
- timer = timer + Time.deltaTime;
- }
- else
- {
- spawnAsteroid();
- timer = 0;
- }
- }
- 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);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement