How to make a Quiz Game with Multiple Choices in Unity
HTML-код
- Опубликовано: 19 июн 2024
- Consider donating to help me keep this channel and website alive : paypal.me/supportTheGameGuy 💖
In this video im gonna show you how to create a quiz with multiple choices from scratch and special thanks to @Brackeys because i'll be mainly extending and improving his quiz video tutorial to include multiple choices instead of true and false.
The quiz manager is completely dynamic, you could include as many questions as you want and also there is no limit to the options. So it all depends on how you want your game to be like.
And I will be uploading the part of this quiz game soon. so stay tuned!
Some more unity tutorials which might be useful :
How to throw knife in UNITY :
• How to throw knife usi...
How to make an AWESOME game Menu :
• How to make an AWESOME...
How to make level saving System :
• How to make a simple L...
Remote Configuration by BRACKEYS :
• CHANGE YOUR GAME ANYWH...
Game difficulty by Brackeys :
• Difficulty in Video Ga...
How to make first person game in UNITY by BRACKEYS :
• MAKING YOUR FIRST FPS ...
Some interesting and fun Unity videos by DANI
I made an evil bot my friend :
• I Accidentally Made an...
I turned RUclips into giant battle royal game :
• I Turned RUclips into ...
I made a game in 30 Minutes :
• Making a Game in 30 Mi...
Music: www.bensound.com 🎵
Some of you might encounter some error with
public Text QuestionTxt; instead of using this, Use this " public UnityEngine.UI.Text QuestionTxt; "
also with this one: options[i].transform.GetChild(0).GetComponent().text= QnA[currentQuestion].Answer[i];
instead of using those statement, use this instead:
options[i].transform.GetChild(0).GetComponent().text= QnA[currentQuestion].Answer[i];
Thank you
omg thanks mate. I keep scratching my head what's wrong
thanks bud!!
Just use "using UnityEngine.UI;"
May both sides of your pillow be cold every night
Thank you for this really great tutorial! As a few others have said - it is really good for school homework.
Great Man! Really Appreciate your effort and skills, You helped me a lot, Thanks.
Thank you so much, I have to make a game for a school history project and your videos are saving me! #brazilhere🇧🇷🇧🇷🇧🇷
Thank you! Very good tutorial!
Blessed video man! Thank you
If you're using buttons and Unity can't find your options text, try using in the options[i].transform.GetChild(0).GetComponent().text = QnA[currentQuestion].Answers[i]; line.
I tried this but it still didn't work, what should I do?
@@rmak2597 Did you make sure to put "using TMPro;" on top?
life saver
Thank you!
you save my life :)
Discula esto tambien se puede realizar en RA con unity vuforia, en un groud plane o un target?
Really cool!
ty very well explained
Why the generateQuestion() is showing this error.Index was out of Range. Must be non-negative and less than the size of colllection.
thanks for the tutorial, it was so useful for me. if I want to add an image per question to ask about the image, how should it be the code?
hi! did this tutorial work for you? are your choices showing up on the placeholder?
yeyyyy it worked!!!! Take noteee don't use text mesh pro, just use a normal text in ui
Okay ty
use TextMeshProUGUI
@@pvlcity7439 send code for answerscript and quizmanager
Can u help me 😭
Hello,I was correctly implementing the code but there was a problem during the on run time index and the out of range error showed what I do to solve that error
Please how did you create the other screen which shows your 2d scene panel? Mine is not showing
What if I wanted to add all the questions via code inside of the script (instead of via the editor), would that be fairly easy to do?
(reasoning: I'm planning on adding a way to import questions/answers via a JSON script later)
Also, a suggestion. Would you either get a clearer mic, or turn off the background music? There are parts of this that are very difficult to make out what you're saying!
thanks veryhelpful
Hi, i am facing an issue. When i click a button it displays both the texts “current answer “ and “wrong and” at the same time. Please help
Hi, thanks for the tutorial, I'm programming a game for some class practices. I've been looking for how to add your tutorial within a category system like science, food, geography... But I can't implement it. I am new to programming. If you could help me I would appreciate it. Thanks for the tutorial again.
Look up scriptable objects. THey can act as data containers where you can add different sets of data and call them based on user input.
Thank you~^^
Hello! When i select all buttons and then drag and drop the answer script to all of them, Unity doesnt show me the same "Answer Script" window like yours. There is no "Is Correct" or "Quiz Manager" fields and i cannot set the reference to QuizManager like you did because there is no option for that. There is only "Script: AnswerScript".... whats wrong?
SAME AS ME
Which Unity version did you use to create the game??
Why element 0 question 1 doesn't not show the question and the answer buttons?
why it states to my unity that the "Text" word in line 11 of quizmanager that it cant be found??
All of my Script and Scene options are either not listed or greyed out, so i could not follow this tutorial to completion. For example there was no option to change the reference for quizmanager, just a greyed out bar. Similarly there is no options tab in the "QuizManager" file, just a greyed out script with nothing below.
cannot drop anything into the questiontxt thing in the quizmanager gameobject
I have check everything but cannot slove issue ,my button text isnot changing when i play what could be the issue can someone help
hellppp i have this error:
NullReferenceException: Object reference not set to an instance of an object
QuizManager.SetAnswers () (at Assets/Script/QuizManager.cs:30)
QuizManager.generateQuestion () (at Assets/Script/QuizManager.cs:44)
QuizManager.Start () (at Assets/Script/QuizManager.cs:16)
Unity wants me to add MonoBehaviour to the QuestionsAndAnswers script.
When I do so, i can't manualy write the Questions and Answers into the QuizManager.
But if i dont do it, it says "'QuestionsAndAnswers' is missing the class attribute 'ExtensionOfNativeClass'". When testing one Question+Answers are shown onscreen, but nothing happens when clicking the buttons.
I did everyhitng according to the video, except of e.g. the 'public Text QuestionTxt', where i had to use 'public TextMeshProUGUI QuestionText' as i can't add Test, but only TMP.
Is this the reason of my problems? Or is it something else?
i'm not sure if you'll see this, but if you have to add monobehaviour (no idea why!) you can create new objects, add the qna script to those objects and write the questions and answers into them, then add them into the question manager object, if this makes any sense, that works
u are my fav guy
Can you help me in adding Progress bar to this game?
How to add audio to a quiz question?
help! i get only thr "wrong answer" message from debug log
Can someone help me? I make like author, but I can't to set questions and answers in QuizManager, I have only field where text "QuestionAndAnswers". What I make wrong?
Hi I'd like to ask will there be any difference if instead of using just "Button" I use "Button-TextMeshPro"
1:48
Will there be any difference in the coding and if so, what is it?
You just need to improt the tmpro to the script. If u have any doubts related,just drop a reply comment below.I will try to help u
@@SwampowlStudios-td8bk Legend thanks for the help i was looking for the text mesh pro command in the code
@@SwampowlStudios-td8bk The only thing is i dont know why the size tab is not appearing in the Quiz Manager inspector window in the options tab like it is in the video?
@@mazukai6525same problem here
nice vedio by i didnot understand tthis code Scoretxt.text = score "/" total question there is another paramenter but i didnot understand is it ! or : parameter plz clarify me
why does it say to me "Can't add script component 'AnswerScript' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match" when I drag the sricpt in 14:37
Hello! Have you already solve the problem?
error CS0246: The type or namespace name 'MonoBehaviour' could not be found (are you missing a using directive or an assembly reference?)
check you script name and check you in code script name
they should be same
In the QuestionsAndAnswers script add "using UnityEngine;" above [System.Serializable]
I don't know if you check comments from videos this old as of late, but I could really use some help. I did everything according to the tutorial and it appears the game is working, but I can't press any of the quiz buttons to progress. I've double checked and the everything looks to be the same as the video, I even downloaded the assets directly from your homepage just to be sure. Any ideas?
So the buttons are like uninteractable at the start of the game?
@@TheGameGuy Pretty much. When I try to test the game out, clicking on the buttons does nothing. I made a few test projects with buttons and they're not working either, so now I think it's a problem with my version of unity or my laptop.
Try using a different version of unity and if you are not already, use the unity HUB to download the new version.
@@travissloan9411 у вас получилось?у меня такая же проблема
Help me pls, I'm gettin this error :
NullReferenceException: Object reference not set to an instance of an object
QuizManager.generateQuestion () (at Assets/QuizManager.cs:43)
QuizManager.Start () (at Assets/QuizManager.cs:16)
GameObject[]' does not contain a definition for 'length' and no accessible extension method 'length' accepting a first argument of type 'GameObject[]' could be found (are you missing a using directive or an assembly reference?)
Im using Sublime Text 3 for coding
please answer when i hit play no questions appear until i click 1 button is this supposed to work like this?
@@reginadominique4357 Did u try with "Length"?
thanks for the tutorial, only to me sometimes it tells me it's wrong but i know is right?
WOW
For this app how to write code for previous button
Hi, why cant i drag and drop the Text to the Quizmanager's QuestionTxt? On your video on 14:50 whenever i drop it, it doesnt work it has the no symbol
Nevermind I figured it out. Since only TextMesh is available and there are not Text only option, I changed " public Text QuestionTxt; " into " public TextMeshProUGUI QuestionTxt; " and I also added using TMPro
Do you have problem with element 0, mine is in question 1 which is element 0 the question and answer doesn't not shownup
@@jaymarkvergara4864 Hello! Have you already solve the problem?
I can not add the script into the buttons. It said the script class cannot be found. I do not have compile errors and the file name match the class. What should I do ? (I have both script and scene in a different file of my other game)
same
May I know how to add questions and answers using scripts? I am planning to use firebase to store questions and answers.
hello. were you able to find the answer? i am also planning on doing the same thing (and also using firebase)
how do select all of the stuff
can you add some life or chances stuff?
Thanks Bro.. But i following every step. but the button and the question do not change
guys help me please i cant drag the Text in Question Txt IDK why maybe its for there are Text (TMP) is that problem pls hrelp me
Me too
👌👌👌
Why couldn't not drag my quiz manager to my answer script?
I don't know why but it doesn't work... The Debug.Log always displays "Wrong Answer" even I answer it correctly...
hello how can i change the question to be image as well pls help
ruclips.net/video/mtBWaXA96r8/видео.html Check this out
It shows:
error CS1061: 'TextAlignment' does not contain a definition for 'text' and no accessible extension method 'text' accepting a first argument of type 'TextAlignment' could be found (are you missing a using directive or an assembly reference?)
Can someone help me with it please? I did on this many hours and it doesnt work :(
make sure to put "using UnityEngine.UI" at the top of the script
im having the same issue and im trying to see the replies for your post but its taking for ever lol
thanks for asking this question tho im glad that im not the only one thats got this issue
I had same problem. You have to put "using TMPro;" and if it doesn' t recognize "Text", write "public TextMeshProUGUI QuestionTxt;" or "GetComponent().text = QnA[currentQuestion].Answers[i];" Hope it helps.
Hello can you hep me with thi error? "The referenced script on this Behaviour (Game Object 'QuizManager1') is missing!"
i think you just have to drag the script in
@@Abab-kx1nk Thanks! But sadly i got another error it says "Null reference Exception: Object reference not set to an instance of an object"
For the *Copy/Paste gang* 😜
Grab the assets from : thegameguy.net/resources.html
Grab the Complete Project from my Patreon Page : www.patreon.com/posts/46461491
thanks bro, it really helped us
Here I got the following error: "Assets\QuizManager.cs(11,12): error CS0246: The type or namespace name 'Text' could not be found (are you missing a using directive or an assembly reference?)" , so I had to write in the beginning of the Script. I hope it helps someone.
I did get this error but i have no idea how to fix it
Can you teach me one to one?. I am a children's book author and creating many interactive AR quiz on body safety rules
I got everything to work, but if I answer correctly it will ask the same question again later on. How do I stop that?
That is wierd, it shouldnt be happening as we are getting rid the questions that we have already answered.. leaving only the unanswered ones
So, what if you wanted a question that had more than 1 correct answer? How would you do that?
This is a good question. I was wondering about that too...
that's actually a good question and now that think about it, probably we would have to make an array of correct answers that hold the indexes of the correct answers and each time we answer a question instead of just checking for a single value we would have to check for all the correct answers
@@TheGameGuy you are too too good!!!
@@TheGameGuy instead of the script reading the text from the button , cant we just assign script to the correct button that would just increment value of score when u press?
@@TheGameGuy Hello! I'm new to this and i really need this because i'm making a quiz with multiple correct answers, i would really like to see this in code if you wouldn't mind helping
Its is not working for me :-( i tried it twice
choices aren't showingggg, helpp
Maybe i can help someone with this problem even though this comment already 2yrs old, if you're using newer unity, make sure you use text and not text meshpro, you can find text in the legacy option
Hi someone can help me to improve my game I need it for a school project and I need that when the answer is wrong the correct answer button goes green also if somebody know how to randomize the answers so the answers never repeats positions after replaying the game I will appreciate it too much. Pd: sorry for my English
I trusted you
Hello thanks for the tutorial
I have a doubt if my question is in the form of audio how can I implemented this script?
Did you figure out?
I've already reviewed the code and so far I don't understand why the answers worked the first time, but on the other attempts, they always come back incorrect and only one is true. I've already looked at Inspector and the code and found no difference. What can it be?
Umm, that's super unusual. Are you repeating the same questions multiple times? Are there any errors related to the questions array? have you tried running the same project on a different unity version?
same thing for me. only one is correct idk what to do
Here you should not apply Answerscript->Anwer() method to all buttons at once. In Video he has done correct.
I am encountering the same problem, is there a fix for this?
@@VamshiRao Bro wtf...why is it like that? I was debugging the code and was wondering why the answers are always incorrect. I'm confused lol
Got an error ArgumentOutOfRangeException. Help!!!
Fixed it?
fix?
@@pvlcity7439 yeah but i used another tutorial on Spanish
How could i make this Work with Multiplayer?
want to know it too
how to check if the answer is correct ?
if(QnA[currentQuestion].CorrectAnswer == i+1) ?
yes
i have a problem at 9:56 it say "cannot implicitly convert type 'char' to ;string"
can you please help ?
Add .text to this line
QuestionText.text = QnA[currentQuestion].Question;
Why my code isn't working?I copy all the text and code.
I pressed play and it would say correct answer but wont move on to the next question? How do I fix this?
Can you see any error in the console?
@@TheGameGuy I fixed that issue thks as I forgot to add Debug.Log. However the error "ArgumentOutOfRange" keeps popping up even though I added the extra bit of code from part 2 to fix the issue??
Where is the next video ?
what if I want a 5 shuffeled questions from 10 pleeaaase help I am a 0 in coding Thank you so so much
hey. did you found the answer? I also want to shuffle 3 questions from 10 questions
why all the result is wrong answer? even though it was the correct answer
I don't have the option to add text in the UI list only text(TMP), and I can't drag that into the question text option in the quiz manager, did anyone else have this problem?
I also have this problem. Did you find a solution to this? Thanks.
@@fei6383 hey, I cant go on my computer atm however there was a drop down in the same bit as text tmp that text in it, also this is only part 1 of two, so it might be solved in part 2
@@TheMarnoch21 alright, thank uuu!!
Use public TextMeshProUGUI QuestionTxt; in QuizManagerScript
@@volkovaAgnese hey is there any other solution even i am stuck with that!!
I did everything as in the video, but for some reason, sometimes, the number of the correct answer I chose in "QnA" in the game is shown as "wrong answer", but as soon as I change the number in the correct answer in "QnA", it will immediately work.
At the moments when it shows "wrong answer" all the buttons that I press give me "wrong answer". Help me pls... :((
did you find a fix for this?
just ignore the 0 in elements starts with 1 hope it helps
Same issue, any idea on how to fix?
Found a fix, my quiz manger was using just 1 answer button for all 4 answer buttons, make sure your quiz manager has all 4 set
@@zudla9959 how to fix the 0elements doesn't not show the question and answer
My answers always get wrong. Can you help me?
did you solve it already? please reply I have same problem here
QnA does not appear in quizmanager in unity
How can this be?
i have the same
@@aqualix4662 May be you forgot tis in the QuestionAndAnswer-Script: [System.Serializable ] (at the beginning of the script)
hi, i'm trying to make the video exactly, but at 8:58 void SetAnswers()
{
for (int i=0;i
Try using a upper case "L"
try " for (int i = 0; i < options.Length; i++)"
how can i make "multiplayer" quiz game for android and upload it on google play
i want steps recommended video to watch and program to use
So u don't know any SOLID princeple? ( class name QuestionAndAnswer?, mabe better do class question and another class answer and the override ??)
Hey, you made a mistake. You get only 3 questions instead of 4. You need to add:
public int trigger_counter = 0;
and
private void Start ()
{
trigger_counter++;
if (trigger_counter != 1)
{
QnA.RemoveAt(currentQuestion);
}
generateQuestion();
}
in the QuizManager script.
Hey bro how about this error ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
@@ilhamhafiez5511 anjai jumpa kat sini HAHAHAHHAHA
@@syahmiasyraaf9965 CARI MASALAH ERROR BANG HHAHAHAHA
It is 5 months later but I just want to thank you so much for this fix!
Didn’t work
Could you be more specific?
12:44
When I launch the game, the initial text remains but the first question does not appear. Can you help me please.
check the functions. U might made an error on syntax
Not sure if this will work for everyone but in the setAnswers() function i wrote ==i not ==i+1 like this:
if (QnA[currentQuestion].CorrectAnswer == i)
{
options[i].GetComponent().isCorrect = true;
}
I kept getting wrong answer until I wrote it like this.
Maybe you started the loop from i=1, then you dont need to add 1 to the question index. in the video he started the counting from i=0 but the question index starts from one, then you need to add 1 to get the right answer
It is same as brackeys tutorial, even you copy his sentence
Actually, i did mention that this is an expansion to Brackeys tutorial as many developers wanted to have multiple choices instead of 2 and also be able to use images as answers instead of text.
@@TheGameGuy oh that's right
Hhj
not working
because of the coding?
hi somebody help me for my collage final project I got this error T,T
NullReferenceException: Object reference not set to an instance of an object
QuizManager.generateQuestion () (at Assets/Scripts/QuizManager.cs:46)
QuizManager.Start () (at Assets/Scripts/QuizManager.cs:16)
my answer didn't come out also question too help me pleaseee
Oh maybe your object name on unity didnt same as you declare on script. Recheck back QuizManager did you rename it with capital letter or not
Me too this is my problem, I triple check all my file name and it's the same, the letterings and uppercase or lowercase still it's null. Do I need to reinstall my unity and visual code?
SAME AS ME, I ALSO PROCEED ON MY FYP, IS THERE ANY SOLUTION? I ALSO CANT IMPORT QUIZ MANAGER ON ANSWER SCRIPT
error CS0246: The type or namespace name 'Text' could not be found (are you missing a using directive or an assembly reference?)
make sure to put "using UnityEngine.UI" at the top of the script
@@TheGameGuy I follow your code in the first part.
@@TheGameGuy using the "using UnityEngine.UI" still not works for me. It only gave me a lot of errors sir
if ur using tmp then do TextMeshProUGUI instead of Text