Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float r = Random.value * itemProbabilitySum;
- float sum = 0;
- Item selectedItem = null;
- foreach (Item item in itemTypes)
- {
- if (r >= sum && r < sum + item.probability)
- {
- selectedItem = item;
- break;
- }
- sum += item.probability;
- }
Advertisement
Add Comment
Please, Sign In to add comment