- Home /
Make a random number get chosen less or more? (C#)
So I have a little problem with one of my power up spawns. I'm using a random to spawn out a random power up:
//Random range between every power up
int index = Random.Range (0, PowerUpsPrefabs.Length);
Now I have a power up called "power up 1" and it deletes all of the enemies on the map, but here's when the problem shows up! Since it is a random it will just spawn out a random power up, but this will also mean that power up 1 will be able to spawn out all the time, which will make the game unbalanced.
Is it possible to make it so that the other power ups can spawn out more often and make the "power up 1" spawn out less to make it more rare?
Why did you delete your original question and post almost the same again? Why did you not edit your first one? The "edit" button is in the context menu which appears when you click the gear at the top right of your question
Answer by Bunny83 · May 25, 2016 at 09:58 AM
Has been asked hundreds of times.
You might simply use WeightedRandomizer or simply search for "Unity weighted random" and you get tons of posts about that.