- Home /
Simple Questionnaire Game Logic?
What I want to do, think of a simple multiple choice question with only one correct answer.
Questions: What is 2+2?
A: 2 B: 22 C: 44 D: 4
Obviously D is the correct answer in this case. But the point of this is that I have a text file with about 1000 or so questions and each question has 4 possible answers with only 1 being the CorrectAnswer. I want the game to display this with GUI and I already know how to do that. If the answer is correct, then move to the next question randomly, but.. do not ask this question again. Kind of unmark it from the list of questions to show. But if its incorrect, put this this question back into the pile and randomly move to another question eventually asking this question again. I cannot figure out a few things on doing all of this.
What is the simplest way to produce this. Should I try accessing a text file with all the questions and answers, or should i create a script that contains them all in blocks. and the questionnaire script access that instead. And how should I do the randomizing? Random.Range? and of list? or array? How to unmark(Possibly could just Question[1].Remove or something) This is really important to me so any help would be greatly appreciated. I'm not trying to ask for a fully written script, I just need some help/advice Thanks.
Answer by hexagonius · Dec 09, 2014 at 09:31 PM
A friend of mine is using XML parsing for that kind of stuff. Jason might be better do as well. I would stick to the text file since it's easier to manage and external to your scripted logic. You should definitely check on parsing. Then, you could assign unique numbers to your questions and answers, read them all once into a list and move already answered ones from that list to a used list, or something like that. Or parse the numbers back into a used text file for later. Parsing... ;)
Answer by Vandarthul · Dec 10, 2014 at 03:14 PM
I'm not sure if this is the best solution or an optimal one but I would try to do this:
Create a class that holds Question text, A, B, C, D choices, the true answer
Create a list of that class and pull all questions to the list.
Select random list item(Random.Range would work just fine)
After the question is answered, tell the player if it's being answered corretly and copy that list item to another list so you can store and reach already asked questions maybe with the answer given by player too, or just remove the list item.
That's pretty much it for me I think.
Your answer
![](https://koobas.hobune.stream/wayback/20220613173644im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Before I waist a ton of time... Need help 1 Answer
A node in a childnode? 1 Answer
Scripting and Coding Dictionary 0 Answers
How to add elements from a List of another class to another List (C#) 1 Answer