My solution would be something a little more simple/approachable than most here. This won't be as "Random" as the others mind you, but the player won't know it anyway either way, right?
int CurrentID;
public GameObject[] myArray;
GameObject mySelectedGameObject;
void Start(){
InvokeRepeating ("SelectRandom", 0, 1);
}
void SelectRandom(){
int lastID = CurrentID;
int randomInt = Random.Range (0, myArray.Length);
if (randomInt != lastID) {
mySelectedGameObject = myArray [randomInt];
CurrentID = randomInt;
} else {
if (lastID != myArray.Length-1) {
mySelectedGameObject = myArray [++lastID];
CurrentID = lastID + randomInt;
}
else{
mySelectedGameObject = myArray [--lastID];
CurrentID = lastID + randomInt;
}
}
}
Trending Articles
More Pages to Explore .....