Random Float Variable

This is horribly frustrating, maybe I’m just doing it wrong. I want to spawn a random(pre-made) object at an empty gameobject. I think that the easiest way to do this would be to call a random float number, like; 1-5. And then I’d use an if function to check the variable, and spawn the object if it’s the right number.

You can use Random.Range(0,100) and compare it to the percentage limit:

  if (Random.Range(0, 100) < 20){
    var clone = Instantiate(...);

The chance to instantiate the object in this example is 20%

Your question is ambiguous, can you explain more? Do you want to spawn ONE type of object at ONE place, on a 20% chance of doing so? If so, just compare Random.value to 0.2, if it’s less, spawn away. Or do you want to spawn ONE type of an object at one of FIVE possible places? If so, you can have an array of 5 empty game objects and use that INTEGER to pick an element (0 to 4 by the way), and parent the new object to the chosen empty object. Or just assign the new object’s position same as the chosen empty object.