Uploaded August 2026 | Updated September 2026, 3 hours ago
If your loot table is a pile of ifs, you do not have a system β you have magic numbers that break when someone asks for Legendary to be a little rarer. This video builds a weighted loot table instead: each item gets a weight, you pick in proportion to those weights, and the picker code stays put. We walk through prefix sums plus binary search on a number line, then the alias method that turns the same weights into two random calls after setup. A small Unity helper maps an AnimationCurve onto that same weight table so designers can tune rarity without rewriting thresholds. Same odds, no hardcoded luck.
algomaster.io/learn/dsa/random-pick-with-weight
Want to support me? π
Buy me a coffee! ko-fi.com/adammyhre
π Subscribe for more Unity Tutorials youtube.com/@git-amend
Discord: discord.gg/FDRZGQBBUC
#unity3d #gamedev #indiedev
β¬ Contents of this video β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬
0:00 Prefix-Sum and Binary Search
4:27 Alias Method
9:08 Curve Weights
9:50 Demo
*Source code:* gist.github.com/adammyhre/82b04c106bdee0fc6af1cc93be3d76b3
More Useful Code:
github.com/adammyhre?tab=repositories
Unity Utility Library: github.com/adammyhre/Unity-Utils
Lock Inspector Hotkey: gist.github.com/adammyhre/4754f731a93bf1cab0d1385ccfa23642
*Other Recommended Tools* _(Affiliate Links)_
Ultimate Preview - assetstore.unity.com/packages/tools/utilities/ultimate-preview-bundle-340976?aid=1101lw3sv
Mouse Shortcuts - assetstore.unity.com/packages/tools/utilities/mouse-button-shortcuts-and-selection-history-228013?aid=1101lw3sv
Init(args) - assetstore.unity.com/packages/tools/utilities/init-args-200530?aid=1101lw3sv
Wingman - assetstore.unity.com/packages/tools/utilities/wingman-your-inspector-s-best-friend-303181?aid=1101lw3sv
Favorites Window - assetstore.unity.com/packages/tools/utilities/favorites-window-123487?aid=1101lw3sv
Scene Notes - assetstore.unity.com/publishers/87819?aid=1101lw3sv
Beautify - assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/beautify-3-advanced-post-processing-233073?aid=1101lw3sv
Odin - assetstore.unity.com/packages/tools/utilities/odin-inspector-and-serializer-89041?aid=1101lw3sv?aid=1101lw3sv
Odin Validator - assetstore.unity.com/packages/tools/utilities/odin-validator-227861?aid=1101lw3sv
Hot Reload: assetstore.unity.com/packages/tools/utilities/hot-reload-edit-code-without-compiling-254358?aid=1101lw3sv
Better Hierarchy: assetstore.unity.com/packages/tools/utilities/better-hierarchy-272963?aid=1101lw3sv
Better Transform: assetstore.unity.com/packages/tools/utilities/better-transform-size-notes-global-local-workspace-parent-child--321300?aid=1101lw3sv
Better Mesh Filter: assetstore.unity.com/packages/tools/utilities/better-mesh-mesh-preview-full-insight-at-a-glance-321364?aid=1101lw3sv
Editor Console Pro: assetstore.unity.com/packages/tools/utilities/editor-console-pro-11889?aid=1101lw3sv
Any Object Finder: assetstore.unity.com/packages/tools/utilities/any-object-finder-286455?aid=1101lw3sv
Kybernetic Tools: assetstore.unity.com/publishers/16747?aid=1101lw3sv
Sisus Tools: assetstore.unity.com/publishers/41398?aid=1101lw3sv
Prime Tween - assetstore.unity.com/packages/tools/animation/primetween-high-performance-animations-and-sequences-252960?aid=1101lw3s
Rabbit Logger - assetstore.unity.com/packages/tools/utilities/rabbit-logger-305396?aid=1101lw3s
*Follow me!*
https://linktr.ee/gitamend
If your loot table is a pile of ifs, you do not have a system β you have magic numbers that break when someone asks for Legendary to be a little rarer. This video builds a weighted loot table instead: each item gets a weight, you pick in proportion to those weights, and the picker code stays put. We walk through prefix sums plus binary search on a number line, then the alias method that turns the same weights into two random calls after setup. A small Unity helper maps an AnimationCurve onto that same weight table so designers can tune rarity without rewriting thresholds. Same odds, no hardcoded luck.
algomaster.io/learn/dsa/random-pick-with-weight
Want to support me? π
Buy me a coffee! ko-fi.com/adammyhre
π Subscribe for more Unity Tutorials youtube.com/@git-amend
Discord: discord.gg/FDRZGQBBUC
#unity3d #gamedev #indiedev
β¬ Contents of this video β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬
0:00 Prefix-Sum and Binary Search
4:27 Alias Method
9:08 Curve Weights
9:50 Demo
*Source code:* gist.github.com/adammyhre/82b04c106bdee0fc6af1cc93be3d76b3
More Useful Code:
github.com/adammyhre?tab=repositories
Unity Utility Library: github.com/adammyhre/Unity-Utils
Lock Inspector Hotkey: gist.github.com/adammyhre/4754f731a93bf1cab0d1385ccfa23642
*Other Recommended Tools* _(Affiliate Links)_
Ultimate Preview - assetstore.unity.com/packages/tools/utilities/ultimate-preview-bundle-340976?aid=1101lw3sv
Mouse Shortcuts - assetstore.unity.com/packages/tools/utilities/mouse-button-shortcuts-and-selection-history-228013?aid=1101lw3sv
Init(args) - assetstore.unity.com/packages/tools/utilities/init-args-200530?aid=1101lw3sv
Wingman - assetstore.unity.com/packages/tools/utilities/wingman-your-inspector-s-best-friend-303181?aid=1101lw3sv
Favorites Window - assetstore.unity.com/packages/tools/utilities/favorites-window-123487?aid=1101lw3sv
Scene Notes - assetstore.unity.com/publishers/87819?aid=1101lw3sv
Beautify - assetstore.unity.com/packages/vfx/shaders/fullscreen-camera-effects/beautify-3-advanced-post-processing-233073?aid=1101lw3sv
Odin - assetstore.unity.com/packages/tools/utilities/odin-inspector-and-serializer-89041?aid=1101lw3sv?aid=1101lw3sv
Odin Validator - assetstore.unity.com/packages/tools/utilities/odin-validator-227861?aid=1101lw3sv
Hot Reload: assetstore.unity.com/packages/tools/utilities/hot-reload-edit-code-without-compiling-254358?aid=1101lw3sv
Better Hierarchy: assetstore.unity.com/packages/tools/utilities/better-hierarchy-272963?aid=1101lw3sv
Better Transform: assetstore.unity.com/packages/tools/utilities/better-transform-size-notes-global-local-workspace-parent-child--321300?aid=1101lw3sv
Better Mesh Filter: assetstore.unity.com/packages/tools/utilities/better-mesh-mesh-preview-full-insight-at-a-glance-321364?aid=1101lw3sv
Editor Console Pro: assetstore.unity.com/packages/tools/utilities/editor-console-pro-11889?aid=1101lw3sv
Any Object Finder: assetstore.unity.com/packages/tools/utilities/any-object-finder-286455?aid=1101lw3sv
Kybernetic Tools: assetstore.unity.com/publishers/16747?aid=1101lw3sv
Sisus Tools: assetstore.unity.com/publishers/41398?aid=1101lw3sv
Prime Tween - assetstore.unity.com/packages/tools/animation/primetween-high-performance-animations-and-sequences-252960?aid=1101lw3s
Rabbit Logger - assetstore.unity.com/packages/tools/utilities/rabbit-logger-305396?aid=1101lw3s
*Follow me!*
https://linktr.ee/gitamend










