- Home /
Question by
gamerofwhatiwant · Dec 22, 2017 at 06:22 PM ·
randomly
I want to randomly pick a wave to spawn everytime
using UnityEngine;
public class BlockSpawner : MonoBehaviour
{
public Transform[] spawnPoints;
public GameObject blockPrefab;
public float timeBetweenWaves = 2f;
private float timeToSpawn = 2f;
void Update()
{
if (Time.time >= timeToSpawn)
{
spawnBlocks();
timeToSpawn = Time.time + timeBetweenWaves;
}
}
void spawnBlocks() // I want to add another one of these and i want it to pick from them
{
int randomIndex = Random.Range(0, spawnPoints.Length);
for (int i = 0; i < spawnPoints.Length; i++) // i want to add one like this for (int i =1;i
Comment
Post what you currently have fully, and be a little more clear about what you want. This is not enough information.
Answer by bhavinbhai2707 · Dec 22, 2017 at 08:17 PM
you can simply check for the value of randomIndex value using if else statements and if certain conditions met then spawn according to that!!