Blueprint chance logic broken?

Hey guys!

First time posting … I am trying to create a chance function. GOLDMinSpawn is 0, GOLDMaxSpawn is 100. GOLDChance is 25. The logic is as follows – if the random int (0-100) is less than or equal to 25, print the value and declare true. If the random int (0-100) is greater than 25, print the value and declare false. Pretty easy. The output is declaring random values and true/false as it pleases. Am I missing something?

Hey Kyle,

Thanks for your question! The issue you are having happens between the time your Branch compares a random integer to GOLDChance and the time your Print Strings check for a random integer; the integer is being randomly generated constantly while everything else is occurring on execution. The Print Strings are receiving a different random integer than the one compared to GOLDChance because of timing.

An easy solution is to create a function that generates and outputs a random integer, so that your Print String nodes and your GOLDChance can check the same random integer. Attach your function to your InputKey node, and attach your GOLDChance check and your Print Strings to the integer output of your function. This way the random integer is assigned once on execution as opposed to constantly.

That should solve the issue you ran into. If that still does not function as intended, please let me know and I’ll be happy to investigate further.

Best,

Ben Halliday

Thank you so much! Worked like a charm and very easy to understand explanation :smiley: