Hi guys. I’m a newbie. I want to select multiple game objects from a list of array that i have stored, and no 2 game objects are the same. This is the code that I have written.
void PlaneDisappear()
{
randomGround = GameObject.FindGameObjectsWithTag("Ground");
iOne = Random.Range(0, randomGround.Length);
iTwo = Random.Range(0, randomGround.Length);
while (iOne == iTwo)
{
iTwo = Random.Range(0, randomGround.Length);
}
iThree = Random.Range(0, randomGround.Length);
while (iOne == iTwo || iOne == iThree || iTwo == iThree)
{
iThree = Random.Range(0, randomGround.Length);
}
disappearGroundOne = randomGround[iOne];
disappearGroundTwo = randomGround[iTwo];
disappearGroundThree = randomGround[iThree];
disappearGroundOne.active = false;
disappearGroundTwo.active = false;
disappearGroundThree.active = false;
}
Surely there is an easier and simpler way. Can anyone help? Thanks and appreciate it!