Object Instantiate

Hii…

I am having 3 types of object suppose red , green and blue.

I want to instantiate like red should come maximum amount of time where as green and blue object count will be less.

And once green or blue object instantiated then next one should not be repeated.

For that i have written logic like this :

 void Update()
 {
      int count = Random.Range(0 , 5);
      if(count == 0)
      {
          // blue 
      }
      else if(count == 1)
      {
          // green
      }
      else
      {
          // red
      }
 }

But here i want to avoid repetition of green and blue object/.

This is rough logic i have written. anybody is having idea for this ?

Thanks.

just save what was last instantiated, and if you are about to do the same, pick again!

int lastPick = -1;
int count;


void Update(){
	while(true){
		count = Random.Range(0 , 5);
		
		if(count == 0 && lastPick != 0){
			// blue
			lastPick = count;
			break;
		}
		if(count == 1 && lastPicked != 1){
			// green
			lastPick = count;
			break;
		}
		if(count > 1){
			// red
			lastPick = count;
			break;
		}
	}
}

Scribe