Making random int with weight change over time

Hello guys.

I’m trying to make a blueprint where a switch on int changes its output randomly, but with a random weight that varies over time.

To be more descriptive, my game spawns four types of enemies, and the idea is that these enemies vary the number of times they will appear over time.
Something that initially started like A:70% - B:15% - C:10% - D:5%, but over time it increased the chances of enemy B appearing, then the chances of enemy C, until it completely reversed and be something like A:5% - B:10% - C:15% - D:70%.

But I can’t find any random action blocks on blueprints that allow you to vary the randomness weight - which is funny because it’s possible to do that with Sound Cue’s random action.

Is there a way to do this in blueprints, and I’m being blind? If not, do you guys have any suggestions on how to make this possible?

Hey there @ZizoMass! So there’s no direct blueprint itself for weighted random so most users tend to roll their own systems for it. I have an example for a weighted loot table here by Ryan Laley that might help you get the gist of what you’re going for.

Disclaimer: Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

2 Likes

Thank you so much for sharing this tutorial! It worked like a glove in my case!

I just had to make some variations to work with Int instead of booleans and add a timeline to change the values gradually, and it worked perfectly!

Thank you very much!

1 Like