Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save xSystemIOx/329e688f98b40bb631b0d77342d09a23 to your computer and use it in GitHub Desktop.

Select an option

Save xSystemIOx/329e688f98b40bb631b0d77342d09a23 to your computer and use it in GitHub Desktop.
Unity C# shuffle object
public GameObject[] locations;
public GameObject[] tiles;
List<int> Num = new List<int>();
int setTo;
int index;
// Use this for initialization
void Start () {
for (int i = 1; i < 17; i++) {
pickNumber ();
tiles [setTo].GetComponent<Transform> ().transform.position = locations [i].GetComponent<Transform>().transform.position;
}
}
void pickNumber(){
index = 0;
while (index == 0) {
setTo = Random.Range (1, 17);
if (!Num.Contains (setTo)) {
Num.Add (setTo);
index = 1;
} else
index = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment