How To Give An Object The Option For A Certain Position

I am trying to randomly place a ball at one of three spots from three pre determined transform.postions. What would be the best way to do this?

Hi,

Generate a random number between 0 and 1 and based on its value (with an if statement), set the object’s position to one of the pre determined transform :slight_smile:

Would looks like that:

float rand = Random.Value();
if (rand < .33f) {
   tranform.position = predeterminedPosition1;
} else if (rand > .66f) {
   tranform.position = predeterminedPosition2;
} else {
   tranform.position = predeterminedPosition3;
}

Of course if you don’t want the different positions to have an equal probability to be picked you can change the values (like .25f and .75f that would choose position 3 once out of 2)