Random but with care and balance
when you work with code, it doesn’t matter what language or subject you use it for, but there is always a library that allows you to get a value randomly.
Well also Unity offers well more than one, as an example we want to simulate a dice to 6 faces or to 20 faces
All this is very nice at the beginning but if not controlled it will lead us to total chaos.
So you have to think of a method that manages the probability, in the case of the dice all the faces have the same weight in terms of probability of coming out. If I want to have a result more frequent than others we have to manipulate it so that the frequency is controlled.
In my case I’m talking about the enemies and power-ups that have been implemented.
In this case I assigned a probability directly to the condition of my specific object. This is not recommended because it works when you know the exact position of the objects in its array.
here instead I always do the same thing but I connect to a variable that belongs to each power-up.