Random Int from Range Question

Hi, me again.

Need some help with getting the Other Random Int that has been selected, see picture below this should help…

What I’m doing is spawning a 2 gates for 2 target points but I want them randomized. So for example Blue gate spawns on the left and then next time I play it could spawn on the right. (This is all hooked up to a Begin Play Event)

So the Random Int chooses a number and it spawns on the Target point but how do I found what number it hasn’t chose so I can spawn the other gate on that… I did look at Shuffling the Array but I’m unsure how that node works cause it has no output…

Anyone could help?

Are you for sure only going to ever have the two target points?

If so, you could have a random bool go into a branch and have your two different cases in the true or false.

branch true if random int = 0

???

There will only be 2 doors for this scenario. However I want both Doors to spawn in the level just not in the same place. So If I set up the Branch with Random Int=0 If it is 0 it will spawn the gate, if it is not 0 it won’t spawn it. With the Random Bool, The random Int selects the target point which allows me to get the transform, Both scenarios would work If I just wanted to spawn 1 door at said place.

I should of explained that better. 2 doors need to spawn in 2 places but never in the same place and random. Thanks for response tho!

I just resolved it. Thank you both, You both got me thinking on the right track… See picture below if you’re interested.

So I set the RandomINT, then called it set the first gate to spawn at any random point. Then made a Branch saying if RandomINT = 0 True then pick 1 from the array to spawn, If not true pick 0 cause it must be 1.

I think maybe that’s what Saxon was getting at.

Thank you both tho!

#AwesomeCommunity

That’s too complicated. Saving the Random INT is ok, but instead of branching it, just use “1 - RandomINT” for the other get.
This will get your 1 if RandomINT is 0, and 0 if RandomINT is 1. (:

I don’t understand it… If you minus 1 from 0 surely you get -1. This is possibly due to my lack of knowledge about integers… ELI5 please eXI.

Explainlikeim5

No, not 1 from 0 :smiley:

You just calculate “1 MINUS RandomINT”.

If RandomINT is 1, you will have “1 - 1 = 0”
If RandomINT is 0, you will have “1 - 0 = 1”

As you can see, the result of the equation is the opposite of the “RandomINT”.

I laughed real bad when I read this… Why I didn’t see that I have no idea.

I need to sleep haha. Thanks very much for that.

Or you could just Random Bool | Unreal Engine Documentation

Since he needs a random INT Value and the opposite of the result, the random bool isn’t that helpful. At least not more than the way he is doing it now.
But nice to know about this node _cDub! (: