Here 's my code. This is designed to get an integer to get the element of an array and use the string as Tags for spawning an object. However, my problem is it usually repeats the random int 3 times consecutively. I wanted to limit the repetition to 2 times consecutively only and still be able to use the integer.
private string[] FirstTags = new string[3]
{
"a", "b", "c"
};
private string[] SecondTags = new string[5]
{
"v", "w", "x", "y", "z"
}
int randomInt_FirstTags;
int randomInt_SecondTags;
void GetRandomTag()
{
randomInt_FirstTags = Random.Range(0, FirstTags.Length);
randomInt_SecondTags = Random.Range(0, SecondTags.Length);
}
This code is where I call GetRandomTag() and spawn my objects. It is called every time the player scores.
public IEnumerator SpawnObjects()
{
GetRandomTag();
yield return new WaitForSeconds(0.8f);
SpawnFirstTags();
SpawnSecondTags();
}