I am a totally beginner on unity c#. I am creating a multiple choice quiz game, it has 5 questions. I would like to randomly load all the 5 questions (and choices) without repeating and after it loads all the questions, a panel will be shown as indicating that it’s the game is done. Currently, it loads random questions (and choices) but repeating the previous and no end.
Hi, given that you are working with a small set of questions/answers you could solve it by having a list of ints with the indexes of the shown questions. When the size of the list its equal to the ammount of questions the game is over. If you want to scale the system to a game where the number of questions could be massive, i suggest that you attach an id to each question so that you can make a HashSet with all the visited ids and then you’ll know what questions to avoid and when the game is over.
I would solve with using two lists, using one as a master question list, and the second as an available question list. The second list is a copy of the first list, your random number is based on the total questions available in the second list. Once you have printed a question you remove that entry from the second list. Then you repeat by getting a new random number using the count of the second list.
Using this you can even have a master list spanning several topics, and then create a second list that only copies a specific topic. That’s a big more advanced but I feel it’s always good to know the possibilities.