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

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?

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 :slight_smile: ) 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.