It seems to work:
//Private Variables
int playerSelection;
//Public Variables
public int[] playerCount = new int[4];
public bool turnFound = false;
// Start is called before the first frame update
void Start()
{
//Intialize player selection value using remander from player count
playerSelection = Random.Range(1, 100) % playerCount.Length;
Debug.Log("playerSelection Value: " + playerSelection);
//Determine player turn
for(int i = 0; i < playerCount.Length; i++)
{
if (!turnFound)
{
if (playerSelection == i)
{
Debug.Log("It Is Curently Player " + ++i + "'s Turn");
}
} else i = playerCount.Length;
}
}
I coded this by the seat of my pants and kinda was ina rush cause I really want to go play some Monster Hunter: Rise right now. Also I misspelt Remainder lol.
Edit:
Just thought of something to make it truly scalable; when Initializing the value for playerSelection change it to:
playerSelection = Random.Range(1, 10*playerCount.Length) % playerCount.Length;
This way you can have a player count greater than 100. Now Iām gonna go get some hunts in.