What i’m trying to do seems simple, but my programing skills are shit.
For example:
Whenever i press a button (i get this part), the scripts calls a method that will randomly set a game object, in my array, active, but when i press the button again, it can try to activate the recently activated object again. So it must check if the next number generated is already active. If yes, it generates once more. I’ve tried several things, but failed.
here’s a piece of the script:
GameObject[] areas;
int randomAreaNum;
public void OpenArea()
{
randomAreaNum = Random.Range (0, areas.Length);
areas[randomAreaNum].SetActive(true);
}
this will infinite loop if all the items are active, you’ll need to account for that and either add it to the while(…) clause or just encompass the whole thing in an if.
alternatively you can have two lists “open” and “closed” and move the area from one list to another (don’t use arrays for this they don’t shrink and you’ll have null gaps)