I would like to create a quizz/trivia game for a personnal project. But I have no idea where to start.
The project should be simple since I only need a main menu, questions and an end screen for the results.
Right now I’ve only managed to create the main menu … But I haven’t figured out how to do the questions.
I already created a widget with a question and 4 possibles answers. But using that method will require me to create a widget for each questions …
Here’s what I got so far.
For the last Widget. My goal would be to dynamically display the number of question. For instance if I setup 30 questions it should display on the first question “Question n° 01 / 30” etc …
Where it says “Question goes here” this text should be replace everytime by a question store in a variable, a text file or anything that works. Same for the answers.
And if the player check the right box and press next, nothing should be displayed on screen but his score need to be store to be displayed at the end of the game.
Thank you for this answer. I’ll try this when I’ll have some time.
Well right now juste by reading I’ll say that I’ll run into some issues since I’m not a pro (Data Table part)
But first I’ll try to figure it out myself just using this answer. And if I have question or issues I’ll ask
Thanks again.
also i would check out the thread linked below as the person there is attempting to create a similar system. like Everynone said though i would create a datatable to hold all your questions and answers then you just need a function that compares the selected answer to the correct one.
Well. I tried looking at your link Thompson. But all I manage to do is this:
I have no idea how to link my text to the text reference from the widget.
And Everynone I’ve only been able to create the Struct and the DataTable.
This part’s in chinese for me:
Thank you. For now it’s working like it should. But I have one question. I don’t really understand how the Integer from the Struct work.
I guess it’s to determine wich answer is correct. If so how does it work ? 1 = Answer 1 2= Answer 2 etc … ? And if that’s correct how can I use it to determine if the player check the right answer or not.
Ok great. I’ll check that out. Right now I’m very confused about something …
My questions are not aligned. The basic text that get replaced in my widget is centered and anchored to the center of the screen.
When the questions is short. The text is centered. But when it goes to a longer question (around 30 characters) my text is aligned to the right.
Setting the anchors correctly would work better, cleaner, neater and with less elements, and would work with all screen sizes. You’d need to remove the manual offsets you punched it. Or choose the central icon from the anchors menu and ctrl+click and then shift+click it to reset it all.
It seems to do the trick because it becomes a new canvas child with default settings rather than custom offsets.
Can’t get it to work with me…
I think I did it right. But now I don’t know how to link the old part that set the text (up)
With the new part (bottom).
I tried adding a print string but when I check a box and press next nothing happen.
You need both of them going off, sequence node is your friend here. Also make sure that the Correct Answer in the DT is set to something else than 0. Also make sure that row names are numerals.
To be honest, I’d store the correct answer in an int (when you set widget text) rather than access the DT twice.
The row names are 1 to 5 and the answers are not 0.
I added a sequence node but now even if I pick the right answer I have a failed answer …
I have no idea how to store a variable after I set the widget text. All I need is to store that variable. If the player choose the right answer +1 to the Score variable if not +0.
I know how to add a variable and change it’s value. But right now I have no clue on how I’m supposed to link that variable to my Set Text (text) when the question is generated from the DT.
I have no idea how to store a variable
after I set the widget text.
Called CorrectAnswerForThisQuestion above.
If the player choose the right answer
+1 to the Score variable if not +0. I know how to add a variable and change
it’s value. But right now I have no
clue on how I’m supposed to link that
variable to my Set Text (text) when
the question is generated from the DT.
Do note that I’m not giving you the whole correctly working setup here, these are just elements allowing you to do it. You need to logically organise it.
So check if the correct answer is selected first, count the score, and then load the next question. Sorry, no time for more details. Not at the moment. I can have a closer look at it on Monday morning maybe. In case you can’t get it to work right.
It might just work fine if you run it in the other sequence order than in my screenshot. onClick should check the answer and then load the next question. You probably will want to setup some logic that loads the first question, too.
Well still not working for me … When I pick the correct answer it tells me I’m wrong …
I have 5 rows in my DT named: 1, 2, 3, 4 and 5
For example at the row number “3” the correct answer is the answer number 4 (A4). So in the “CorrectAnswer” integer I typed “4”
But in game if I pick the answer number 4 → My string pops up
.
(Update: I just tried every answer on this question and I only got a “success” on the third answer not the fourth …
I don’t get it … Is my “CorrectAnswer” int wrong then ?
It’s far from perfect but works well for what it is. Based on what we discussed above and comes with a couple of extra features. Feel free to take it apart and see what makes it tick. The entire logic is in the widget.