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