Announcement

Collapse
No announcement yet.

Setting up random functionality

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

    Setting up random functionality

    Hello all.

    I was wondering the best way to set up a random functionality. For example, I tell the program to choose a number between 0 and 3. If 0, it displays question 1, 1 displays 2, 2 shows 3, and 3 shows 4.

    I have this part working, but am running into an issue with the reassignment of numbers; Once 0/question 1 is shown, 0 should then be assigned to show question 2 as well, so both 0 and 1 would show question 2. Likewise, if question 2 is shown, 1 should move to question 1, and remove from question 2 so that there is no chance of hitting the button and it not showing anything different.

    I'm attaching a few screens to show an example of how I have it set up; The Event Graph section of that (the part before is just checking to ensure not the full number of questions have been shown), the Check KC1 code (which should be handling the checking and reassignment if 3 then 2 and so on are checked. I have 4 total, each with the first branch checking the one in question (so 1 checks 1 first, and so on, like 3 does below)), and the Cannot Choose code (just makes it so that the Boolean is false and attempts to reassign the number 31 to its array to ensure that it won't be checked when I have all 30 intended questions up.).

    As noted, I plan to expand to have 30 questions, but am currently just using 4 as a test. Today I also noticed that on some, if two have been shown prior, nothing will be shown/changed on the fourth selection. For example, if KC2 and KC3 are both shown and it rolls to show KC4, then no matter what it rolls, 0-4, even though 0 should still be assigned to 1, it will not show question 1.

    I'm at a loss and am currently working on a little graph to try to determine any pattern, but would also appreciate any help.

    Oh, and I have been asked to do this via Blueprints, if any are wondering why I don't try via C++.

    #2
    Hello, an easy way could be to fill an array with all your questions, use shuffle and then get questions from 0 to end in this new order.

    Comment


      #3
      Hi,

      Thanks for the quick response and help. Sorry to bug like this.

      I have an array with numbers referencing each question, and honestly, I feel like I'm just overlooking something simple here and trying to overthink things (that tends to be the case for most issues I come across :P). I set up a shuffle per your suggestion, but still can't remove a number utilized before or change up the numbers connected to each question. I've attempted setting it up to remove the current value after showing, and even (as you'll see in the picture below) manually telling it to remove an integer within (array has integers 0-3), but 0 still shows up in the latter case, with the current value randomly chosen still showing in the former.

      So am I overlooking something super simple or do I have this set up completely wrong?

      Comment


        #4
        I did this quick to sshow you what you can do. This is only basic mechanics for array and you'll have to adapt to what you exactly want to do.
        In event graph you have on the left the components i put in a blueprint (and put blueprint in level blueprint) to have it working :
        2 cubes to have 2 clickable zones,
        3 text render (question title, question itsself and shuffle)
        an array of text filled on the right
        a variable to know current question in array is used.
        Second picture is only viewport showing cubes setting.

        Click image for larger version  Name:	TextArray.jpg Views:	1 Size:	231.3 KB ID:	1490919Click image for larger version  Name:	TextArray2.jpg Views:	1 Size:	57.1 KB ID:	1490918 ‚Äč

        When you click on left wall you have the 4 questions from 0 to3 and back to start when ended. If you click on right wall then array will be shuffle and you"ll have the 4 questions in a different order.
        Last edited by Fen; 06-18-2018, 09:06 PM.

        Comment


          #5
          Thanks again for the help, I appreciate it. Glad to know I was just overthinking things yet again and making them more complicated than they need to be (a weird thing to be thankful for, I know :P).

          Comment


            #6
            I am happy that helps you. Don't hesitate to come back if you need more help.

            Comment


              #7
              Out of curiosity (and for future reference, just in case), is there a similar way of doing that with integers, or do you have to use the Set Text above? Just wondering what the integer Get would tie into.

              Comment


                #8
                You can do arrays with any type of variable. You just have to select what you want when you create it in variable details (or modify after too) : On top right, the little symbol after variable type selection
                https://docs.unrealengine.com/portal...iables/HT6.png

                Comment


                  #9
                  Good morning,

                  I know that part, I'm just not sure where, for example, the Get node output should connect to. As a test, after I asked, I set up a similar one to the one you provided (thanks again for that, as it helped me understand that method with text ) using integers, but am unsure where the diamond node in get should go, or if it would need to be different.

                  I've tried connecting it to multiple places to continue testing, but, with a test array of 0-4, after shuffling (which shows that the array should be, for example, "1,4,0,2,3"), it still shows in order of 1-4, then 0 no matter what. If I try connecting it to a set int test somewhere (I've tried making a new one as well and placing it in various locations), it does something like, "0, 5, 7, 3, 1", even though there are only 5 elements total, and 5 and 7 are not in the array at all.

                  I'm wondering if there's a set integer function like the set text you showed that I'm missing (have looked both dragging out the int test, get, and right clicking on a blank and didn't see anything in the integer section that looked similar, although I'll be the first to admit I could 'be overlooking. I've also run a search in the right click menu and dragged menu but didn't see anything. If not, just wondering what I'm missing (or if I need to utilize the same get text as done with a text array) for the get part.

                  Also looking at the image, looks like I accidentally disconnected the print string integer-text, sorry. It was connected to the bottom set's integer node.

                  Sorry for asking so many things.

                  Comment


                    #10
                    This is because you modify your integer before print it. Here is a way to have it working with both index and value. (made in player controller to have it working with a key)

                    Click image for larger version

Name:	TestArray3.jpg
Views:	6
Size:	181.8 KB
ID:	1491697

                    Comment


                      #11
                      Thanks (sorry for the late reply, been busy today). I'll do some testing/experimenting on my end and if I still have any issues I'll let you know. I really appreciate the help, and sorry for asking so many (likely newbie :P) questions.

                      Comment

                      Working...
                      X