Created
March 6, 2019 19:56
-
-
Save xSystemIOx/329e688f98b40bb631b0d77342d09a23 to your computer and use it in GitHub Desktop.
Unity C# shuffle object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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