I'm trying to generate a array[25] and fill it with random numbers between 1 - 6. I have created an array but it stops being filled when it hits 5. It also doesn't use the same number more than once.
Can anyone help me on how to fill the array with numbers ranging from 1 to 6 repeating numbers that have already been places?
int rand = 0;
int[] encounterType = new int[25];
void OnStart()
{
for (int y = 0; y < encounterType.Length; y++)
{
rand = Random.Range (1, 6);
encounterType [y] = rand;
print (encounterType [y]);
}
}
Aucun commentaire:
Enregistrer un commentaire