### Search in Sort by:

 Everything Blueprint Scripting Current Space

### Search help

• Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
• You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
• cat dog --matches anything with cat,dog or both
• cat +dog --searches for cat +dog where dog is a mandatory term
• cat -dog -- searches for cat excluding any result containing dog
• [cats] —will restrict your search to results with topic named "cats"
• [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

# Best way to determine chance?

 0 I have been using a method of determining chance that basically has an integer that is random and then if that number is higher than the target integer, do something. I want to know if there is a better way of determining chance by percentage. I see the integer percentage node but I am unsure how it works. So if I wanted something to happen 10% of the time, right now I would do random integer between 1-10 and if the number is equal to 1 let the event happen. Is there another way to achieve this? Product Version: Not Selected Tags: more ▼ asked Mar 28 '15 at 11:35 PM in Blueprint Scripting VigeoJames 116 ● 34 ● 28 ● 42 add new comment (comments are locked) 10|2000 characters needed characters left ▼ Viewable by all users

 0 To determine if something should happen based on percentage: IN C++ : `````` bool ShouldHappen(int percentage) { return (FMath::RandRange(1, 100/percentage)==1?true:false); } `````` In Blueprints: If the input value is 100 then there is 100% chance that it should happen. If the input value is 50 then there is 50% chance that it should happen and so on.. more ▼ answered Mar 28 '15 at 11:53 PM Azarus 1.9k ● 61 ● 52 ● 191 VigeoJames Mar 29 '15 at 12:02 AM Nice, thank you. I should be able to implement something like this. Azarus Mar 29 '15 at 12:03 AM You can create a blueprint function library and create a function so its simpler to reuse :) VigeoJames Mar 29 '15 at 12:14 AM I see it has to do with C+ to actually make a blueprint function library. I know I could do it but it is unknown territory right now. If you know of any tutorials on how to do this that would be great. :D Azarus Mar 29 '15 at 12:28 AM No you don't need c++ to do function libraries! I updated my answer! VigeoJames Mar 29 '15 at 01:30 AM Awesome! Thanks! chriis.aburto Nov 18 '15 at 11:02 PM @Azarus im curious on how the bool ShouldHappen(int percentage); { return (FMath::RandRange(1, 100 / percentage) == 1 ? true : false); } would work because wouldn't there be errors in the code? so lets say in the .h file you have bool ShouldHappen; and in the cpp you structure it that way bool ShouldHappen(int percentage); { return (FMath::RandRange(1, 100 / percentage) == 1 ? true : false); } Im asking because im getting errors and having trouble getting this to work, basically i want a 33 percent chance of a health pickup spawning chriis.aburto Nov 19 '15 at 10:24 PM errors as in trying to return a value in void function add new comment (comments are locked) 10|2000 characters needed characters left ▼ Viewable by all users