Can Someone Help Me

I am making a random event selector this suppose to work I think but a lot of time it hits the last false and i dont know why if i take last false and connect it to first branch end click play button engine crashes can someone help me?

This is not at all obvious, but the problem is that each Branch calls the Random Integer In Range node independently, so for each check, the comparison happens against a new random number.

For example, if in the first Branch the random number is 2, obviously the first check will return false. Now you’d expect the second check to return true, but this time the number is highly likely to be different (could even be 1, this time), so this check will also fail. And so on. This means that there’s a very high chance (75%) for each check to fail independently from each other, which amounts to a reasonably high chance of all checks failing.

As for your crash, I couldn’t reproduce this locally, but I suspect you’re getting an infinite loop because the checks fail too often. Or it has nothing to do with this code and happens because of something that takes place somewhere to the right in the graph…

If you want to keep using the series of branches to compare against the number, you need to do the following.

  1. get the random value once
  2. use it to grab your array element
  3. store it in a variable
  4. use the result for your comparison

However, there’s a much better solution making use of the Switch on Int node, which does exactly what you need:

The Switch compares the value you pass into it with all of its output wires and uses the one that matches the value. Seeing how the comparison is only needed once, I didn’t bother storing the value in a variable. If you still need yit for later, you’ll need to do that, though.

I’ve also passed the selector array’s Last Index into the Random node’s maximum value, so the Get node will still get a valid result even if the size of the array changes. Note that the code still assumes that the array is never empty. To be absolutely safe, you’d have to add a Branch ensuring that the array length > 0 and only continue with the Switch if that check is true.

][1]

I have to thank you a lot to showing my mistake and way to my goal i add a delay this way it keeps firing i m making a run game and thesee are my flors :slight_smile: again thank you :slight_smile:

I don’t understand what you’re trying to do. So you get a random number between 1 and 8 and depending on that create the first, second, … or eighth floor. And after 15 seconds you want to create another random floor (which might or might not be the same one). Why?

Or does this have nothing to do with the earlier random number anymore? That part really confuses me.

I made a infinite run game :slight_smile: for the better look a want to change flor materials randomly so i made 8 different flor and 8 different custom event that calls these flors :slight_smile: