Skip to content

Instantly share code, notes, and snippets.

@curious-username
Last active November 5, 2021 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curious-username/95716c88cf26b2bb111d78e7576839d2 to your computer and use it in GitHub Desktop.
Save curious-username/95716c88cf26b2bb111d78e7576839d2 to your computer and use it in GitHub Desktop.
Spawnmanager changes for big laser
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnManager : MonoBehaviour
{
[SerializeField]
private int _bigLaserCount;
private float _randomNumber;
private int _randomPowerup;
IEnumerator SpawnPowerupRoutine()
{
//every 3 - 7 seconds, spawn in a powerup
while (_stopSpawning == false) {
_randomPowerup = Random.Range(0, 6);
_randomNumber = Random.Range(-8f, 8f);
Vector3 spawn = new Vector3(_randomNumber, 7, 0);
if (_bigLaserCount == 3)
{
Instantiate(_powerups[5], spawn, Quaternion.identity);
_bigLaserCount = 0;
}
else
{
_randomPowerup = Random.Range(0, 5);
Instantiate(_powerups[_randomPowerup], spawn, Quaternion.identity);
_bigLaserCount++;
}
yield return new WaitForSeconds(Random.Range(3, 8));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment