Adding Imperfections?

Hey guys,

Sorry for the non-descriptive title, but I couldn’t think of what to call this. What I have here is a home-made code to make a large cube out of smaller cubes. What I want to do is have it load the cube, but with random “gaps”, or missing cubes. Similar to THIS, but without the red and blue stuff… Following is the code I wrote that “loads” the cubes. If anyone can give me some advice, or give me a start, I will be grateful!

using UnityEngine;
using System.Collections;
//Written By Gibson Bethke ][ GBStudios
public class LoadQuadrateCode : MonoBehaviour {
	public GameObject blockPrefab;
	public int blockSize = 3;
	public int rowSize = 7;
	public float loadingSpeed = 0.05F;
	public bool doneLoading = false;
	
	int iUp;
	int iToTheRight;
	int iBack;
	int upRowSize;
	int actualRowSize;
	
	Vector3 initialPosition;
		
	void Start () {
		actualRowSize = rowSize -1;
		initialPosition = gameObject.transform.position;
		InvokeRepeating("Load", 1, loadingSpeed);
	}
	
	void Load () {
		if(iUp == rowSize && iToTheRight == actualRowSize && iBack == actualRowSize) {
			doneLoading = true;
			CancelInvoke();
		}
		if(iUp == rowSize && iToTheRight < actualRowSize){
				iUp = 0;
				iToTheRight ++;
		}
		if(iUp == rowSize && iToTheRight == actualRowSize && iBack < actualRowSize) {
			iBack ++;
			iUp = 0;
			iToTheRight = 0;
		}
		if(iUp < rowSize) {
		Instantiate(blockPrefab, initialPosition + new Vector3(iToTheRight * blockSize, iUp * blockSize, iBack * blockSize), Quaternion.identity);
			iUp ++;
		}
	}
}

Thanks for your attention, and help guys!

-Gibson


-Edit:

I have implemented Random.Value like Warwick Allison said, and it is working fairly well; is it possible to make it more predictable? The following is my update code.

using UnityEngine;
using System.Collections;
//Written By Gibson Bethke ][ GBStudios
public class LoadRandomQuadrateCode : MonoBehaviour {
	public GameObject blockPrefab;
	public int blockSize = 3;
	public int rowSize = 7;
	public float loadingSpeed = 0.05F;
	public bool doneLoading = false;
	public float amountOfRandom = 0.5F;
	
	int iUp;
	int iToTheRight;
	int iBack;
	int upRowSize;
	int actualRowSize;
	
	float randomNumber;
	
	Vector3 initialPosition;

	void Start () {
		actualRowSize = rowSize -1;
		initialPosition = gameObject.transform.position;
		InvokeRepeating("Load", 1, loadingSpeed);
	}
	
	void Load () {
		randomNumber = Random.value;
		if(iUp == rowSize && iToTheRight == actualRowSize && iBack == actualRowSize) {
			doneLoading = true;
			CancelInvoke();
		}
		if(iUp == rowSize && iToTheRight < actualRowSize){
				iUp = 0;
				iToTheRight ++;
		}
		if(iUp == rowSize && iToTheRight == actualRowSize && iBack < actualRowSize) {
			iBack ++;
			iUp = 0;
			iToTheRight = 0;
		}
		if(iUp < rowSize) {
			iUp ++;
			if(randomNumber < amountOfRandom) {
				Instantiate(blockPrefab, initialPosition + new Vector3(iToTheRight * blockSize, iUp * blockSize, iBack * blockSize), Quaternion.identity);
			}
		}
	}
}

Again, thanks for the help, guys!

-Gibson

Use Random to leave some out.