Announcement

Collapse
No announcement yet.

Random Int from Range Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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..

    Click image for larger version

Name:	RandomINT.png
Views:	1
Size:	140.3 KB
ID:	1159990

    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?

    #2
    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.

    Comment


      #3
      branch true if random int = 0

      ???
      Youtube
      Machine Learning C++ Plugin
      Lindenmayer System C++ Plugin

      Comment


        #4
        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!

        Comment


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

          Click image for larger version

Name:	RandomINTSolved.png
Views:	1
Size:	230.4 KB
ID:	1084321

          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

          Comment


            #6
            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. (:
            Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

            My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
            (Including 100+ Pages Multiplayer Network Compendium to get you started.)

            Comment


              #7
              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

              Comment


                #8
                Originally posted by Conkerballs View Post
                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

                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".
                Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

                My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
                (Including 100+ Pages Multiplayer Network Compendium to get you started.)

                Comment


                  #9
                  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.

                  Comment


                    #10
                    Or you could just https://docs.unrealengine.com/latest...ool/index.html

                    Comment


                      #11
                      Originally posted by _cDub View Post
                      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! (:
                      Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

                      My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
                      (Including 100+ Pages Multiplayer Network Compendium to get you started.)

                      Comment

                      Working...
                      X