[EDITED] Have to random 16 cubes and my concern is that each should be placed at a unique position…means each cube should having (x,y,z) unique so no over placing on one position…just the way the cards shuffled in the game of poker or cube shuffled in Sliding picture puzzle…sorry for the bad English…and Thanks in advance…i am using c#,so help in C# will be much Helpful…Thanks Again…[Edited]… recently my cube’s position starts from (1,4,10),(2,4,10),(3,4,10),(4,4,10)…(1,3,10),(2,3,10),(3,3,10),(4,3,10)…so on… and i have to make the position of cubes to random…and not repeating…
using UnityEngine;
using System.Collections;
public class Random_Object : MonoBehaviour
{
public GameObject cube1;
public GameObject cube2;
public GameObject cube3;
public GameObject cube4;
public GameObject cube5;
public GameObject cube6;
public GameObject cube7;
public GameObject cube8;
public GameObject cube9;
public GameObject cube10;
public GameObject cube11;
public GameObject cube12;
public GameObject cube13;
public GameObject cube14;
public GameObject cube15;
void Start ()
{
ChangePosition();
}
public void ChangePosition()
{
cube1.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube2.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube3.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube4.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube5.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube6.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube7.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube8.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube9.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube10.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube11.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube12.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube13.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube14.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
cube15.transform.position = new Vector3(Random.Range (1,4),Random.Range (1,4),10);
}
}