Since your probabilities sum up to 1, you can basically loop through the objects adding the previous probability to the probability to select the object (this basically generates a probability density function). More clearly:
r = U(0,1) // random value drawn from a uniform distribution if r <= p_1 // if the random value is smaller than the probability to call object 1 obj = 1 // call object 1 else if r <= (p_1 + p_2) // else, compute probability to call object 2, and check if it applies obj = 2 else if r <= (p_1 + p_2 + p_3) // else compute probability 3... obj = 3
Since r is uniformly distributed, you will have the right proportion of object 1, 2 and 3.
Of course, in code, you would probably have a vector of gameObjects with their corresponding probabilities (make sure the probability vector sums to 1).
Example (in c#):
GameObject[] myGoArray = new GameObject[]{go1,go2,go3}; float[] myAssociateProb = new float[]{.5f,.25f,.25f}; float r = Random.Range(0f,1f); GameObject selectedGo; float currentProb = myAssociateProb[0]; for(int i = 0; i < myGoArray.Length; i++){ if(r <= currentProb){ selectedGo = myGoArray[i]; break; } currentProb += myAssociateProb[i + 1]; }