How can I randomize an x and z coordinate from 1 to 10 and then remove that x and z coordinate from the 100 possible combinations? like if i do this
public List<int> xSpawn = new List<int>();
public List<int> zSpawn = new List<int>();
public Rigidbody fallingBlockPrefab;
private Rigidbody fallingBlockInstance;
void Start()
{
StartCoroutine("SpawningBlocks");
for (int a = 0; a < 10; a++)
{
xSpawn.Add(a);
zSpawn.Add(a);
}
}
IEnumerator SpawningBlocks()
{
yield return new WaitForSeconds(SpawnTime);
int randX, randZ;
randX = Random.RandomRange(0, xSpawn.Count);
randZ = Random.RandomRange(0, zSpawn.Count);
xSpawn.RemoveAt(randX);
zSpawn.RemoveAt(randZ);
fallingBlockInstance = Instantiate(fallingBlockPrefab, new Vector3(randX, 20, randZ), transform.rotation);
fallingBlockInstance.name = "FallingBlock " + numberSpawned;
StartCoroutine("SpawningBlocks");
}
but it still spawn duplicates in. So basically say once a cube has spawn at position x=2 and z=3 I don’t want it to spawn at position x=2 and z=3 but still be possible to spawn at x=2 and say z=2 if it makes sense.