I have been all over the internet trying to figure this out. I have 13 fruit, and I want them to spawn where the watermelon is. I want the watermelon to have a 12/86 chance of spawning, the strawberry 11/86 chance of spawning, and etc. I want to make it so every 2 seconds it spawns an object at that set location(where the watermelon is)and the fruit will fall in case you where wonder. Thank you in advance. Script is appreciated.
C#
public GameObject spawnPoint;
public GameObject watermelon;
public GameObject strawberry;
public GameObject apple;
etc..
void spawnFruit()
{
int whichFruit = Random.Range(1,100);
GameObject thatFruit;
thatFruit=apple;
if (whichFruit > 10) thatFruit=strawberry;
if (whichFruit > 20) thatFruit=watermelon;
etc.
Instantiate(thatFruit, spawnPoint, Quaternion.identity);
}
Something like that should work. Just assign a gameObject where you want the spawn point to be and your fruits as gameObjects. In game you just have to call the spawnFruit function.