How to make a Quiz Game with Multiple Choices in Unity
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 KZread into giant battle royal game :
• I Turned KZread into ...
I made a game in 30 Minutes :
• Making a Game in 30 Mi...
Music: www.bensound.com 🎵
Пікірлер: 219
Great Man! Really Appreciate your effort and skills, You helped me a lot, Thanks.
Thank you for this really great tutorial! As a few others have said - it is really good for school homework.
Thank you! Very good tutorial!
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];
@creativekatty8762
Жыл бұрын
Thank you
@stuck4uk714
Жыл бұрын
omg thanks mate. I keep scratching my head what's wrong
@zahrahaziz5821
Жыл бұрын
thanks bud!!
@tank1175
Жыл бұрын
Just use "using UnityEngine.UI;"
@maftplays
9 ай бұрын
May both sides of your pillow be cold every night
Blessed video man! Thank you
Thank you so much, I have to make a game for a school history project and your videos are saving me! #brazilhere🇧🇷🇧🇷🇧🇷
Discula esto tambien se puede realizar en RA con unity vuforia, en un groud plane o un target?
Really cool!
Why the generateQuestion() is showing this error.Index was out of Range. Must be non-negative and less than the size of colllection.
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
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.
@rmak2597
Жыл бұрын
I tried this but it still didn't work, what should I do?
@annamai4680
Жыл бұрын
@@rmak2597 Did you make sure to put "using TMPro;" on top?
@lu-zer
Жыл бұрын
life saver
@user-vv9gx3gk8x
10 ай бұрын
Thank you!
@superfat9242
9 ай бұрын
you save my life :)
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
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
@ernestolobos3224
2 жыл бұрын
thanks bro, it really helped us
ty very well explained
why it states to my unity that the "Text" word in line 11 of quizmanager that it cant be found??
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?
@azzamrashid3726
9 ай бұрын
SAME AS ME
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.
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)
@austinwinkler5329
3 жыл бұрын
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!
Why element 0 question 1 doesn't not show the question and the answer buttons?
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)
I have check everything but cannot slove issue ,my button text isnot changing when i play what could be the issue can someone help
How to add audio to a quiz question?
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)
cannot drop anything into the questiontxt thing in the quizmanager gameobject
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?
@sebkie6934
2 жыл бұрын
hi! did this tutorial work for you? are your choices showing up on the placeholder?
Which Unity version did you use to create the game??
help! i get only thr "wrong answer" message from debug log
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?
@sara18004
2 ай бұрын
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
Thank you~^^
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
@fernandaalmaida4616
Жыл бұрын
Hello! Have you already solve the problem?
thanks veryhelpful
Can you help me in adding Progress bar to this game?
error CS0246: The type or namespace name 'MonoBehaviour' could not be found (are you missing a using directive or an assembly reference?)
@hamidkhalid8150
3 жыл бұрын
check you script name and check you in code script name
@hamidkhalid8150
3 жыл бұрын
they should be same
@user-pc5ef7cq5f
Жыл бұрын
In the QuestionsAndAnswers script add "using UnityEngine;" above [System.Serializable]
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.
@yasasvitennety4885
Жыл бұрын
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.
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)
@domesticaevitaedecus8890
7 ай бұрын
same
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
@harrisriz3093
5 ай бұрын
Me too
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?)
@reginadominique4357
3 жыл бұрын
Im using Sublime Text 3 for coding
@reginadominique4357
3 жыл бұрын
please answer when i hit play no questions appear until i click 1 button is this supposed to work like this?
@GordoMantecoso
2 жыл бұрын
@@reginadominique4357 Did u try with "Length"?
I don't know why but it doesn't work... The Debug.Log always displays "Wrong Answer" even I answer it correctly...
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.
@reenah_zpt157
8 ай бұрын
I did get this error but i have no idea how to fix it
For this app how to write code for previous button
yeyyyy it worked!!!! Take noteee don't use text mesh pro, just use a normal text in ui
@jaymarkvergara4864
Жыл бұрын
Okay ty
@firstnamelastname2971
Жыл бұрын
use TextMeshProUGUI
@firstnamelastname2971
Жыл бұрын
@@pvlcity7439 send code for answerscript and quizmanager
@sundarsundar5822
6 ай бұрын
Can u help me 😭
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 :(
@pooh_jary
3 жыл бұрын
make sure to put "using UnityEngine.UI" at the top of the script
@ZOMBIEFISHERCHIC
3 жыл бұрын
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
@heamorhoid
Жыл бұрын
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.
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?
@blackbars4625
19 күн бұрын
it because i make QnA extends of MonoBehavior, just delete " : MonoBehavior "
how do select all of the stuff
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
@viennaz3522
Жыл бұрын
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
@jaymarkvergara4864
Жыл бұрын
Do you have problem with element 0, mine is in question 1 which is element 0 the question and answer doesn't not shownup
@vladimirsleptsov8844
4 ай бұрын
@@jaymarkvergara4864 Hello! Have you already solve the problem?
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
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
Why couldn't not drag my quiz manager to my answer script?
Thanks Bro.. But i following every step. but the button and the question do not change
Hello can you hep me with thi error? "The referenced script on this Behaviour (Game Object 'QuizManager1') is missing!"
@Abab-kx1nk
3 жыл бұрын
i think you just have to drag the script in
@jessanatividad8730
3 жыл бұрын
@@Abab-kx1nk Thanks! But sadly i got another error it says "Null reference Exception: Object reference not set to an instance of an object"
choices aren't showingggg, helpp
@soulbatguy9621
6 ай бұрын
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
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?
@TheGameGuy
3 жыл бұрын
So the buttons are like uninteractable at the start of the game?
@travissloan9411
3 жыл бұрын
@@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.
@TheGameGuy
3 жыл бұрын
Try using a different version of unity and if you are not already, use the unity HUB to download the new version.
@pvlcity7439
Жыл бұрын
@@travissloan9411 у вас получилось?у меня такая же проблема
May I know how to add questions and answers using scripts? I am planning to use firebase to store questions and answers.
@nerochan4094
2 жыл бұрын
hello. were you able to find the answer? i am also planning on doing the same thing (and also using firebase)
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?
@arjunm1246
Жыл бұрын
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
@mazukai6525
7 ай бұрын
@@SwampowlStudios-td8bk Legend thanks for the help i was looking for the text mesh pro command in the code
@mazukai6525
7 ай бұрын
@@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?
@soulbatguy9621
6 ай бұрын
@@mazukai6525same problem here
Its is not working for me :-( i tried it twice
hello how can i change the question to be image as well pls help
@TheGameGuy
3 жыл бұрын
kzread.info/dash/bejne/n6h2ucORcZycops.html Check this out
Got an error ArgumentOutOfRangeException. Help!!!
@default2181
Жыл бұрын
Fixed it?
@firstnamelastname2971
Жыл бұрын
fix?
@default2181
Жыл бұрын
@@pvlcity7439 yeah but i used another tutorial on Spanish
I got everything to work, but if I answer correctly it will ask the same question again later on. How do I stop that?
@TheGameGuy
3 жыл бұрын
That is wierd, it shouldnt be happening as we are getting rid the questions that we have already answered.. leaving only the unanswered ones
u are my fav guy
So, what if you wanted a question that had more than 1 correct answer? How would you do that?
@edmondeyeemceeezekiels9158
3 жыл бұрын
This is a good question. I was wondering about that too...
@TheGameGuy
3 жыл бұрын
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
@edmondeyeemceeezekiels9158
3 жыл бұрын
@@TheGameGuy you are too too good!!!
@ShonkV
2 жыл бұрын
@@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?
@genos1345
2 жыл бұрын
@@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
What if i want to get the question from ai
thanks for the tutorial, only to me sometimes it tells me it's wrong but i know is right?
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?
@TheGameGuy
2 жыл бұрын
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?
@reyesjohnvincent3469
2 жыл бұрын
same thing for me. only one is correct idk what to do
@VamshiRao
2 жыл бұрын
Here you should not apply Answerscript->Anwer() method to all buttons at once. In Video he has done correct.
@shamenzie
Жыл бұрын
I am encountering the same problem, is there a fix for this?
@romanokeser
Жыл бұрын
@@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
how to check if the answer is correct ? if(QnA[currentQuestion].CorrectAnswer == i+1) ?
@TWITexe
2 жыл бұрын
yes
can you add some life or chances stuff?
How could i make this Work with Multiplayer?
@interestingconsiderations31
Жыл бұрын
want to know it too
I pressed play and it would say correct answer but wont move on to the next question? How do I fix this?
@TheGameGuy
2 жыл бұрын
Can you see any error in the console?
@humayrabakar4207
2 жыл бұрын
@@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??
i have a problem at 9:56 it say "cannot implicitly convert type 'char' to ;string" can you please help ?
@silemayfly4463
2 жыл бұрын
Add .text to this line QuestionText.text = QnA[currentQuestion].Question;
Why my code isn't working?I copy all the text and code.
WOW
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?
@fei6383
2 жыл бұрын
I also have this problem. Did you find a solution to this? Thanks.
@TheMarnoch21
2 жыл бұрын
@@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
@fei6383
2 жыл бұрын
@@TheMarnoch21 alright, thank uuu!!
@volkovaAgnese
2 жыл бұрын
Use public TextMeshProUGUI QuestionTxt; in QuizManagerScript
@kachamsatwika4284
Жыл бұрын
@@volkovaAgnese hey is there any other solution even i am stuck with that!!
👌👌👌
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
@faidurrohman9631
2 жыл бұрын
hey. did you found the answer? I also want to shuffle 3 questions from 10 questions
I trusted you
Can you teach me one to one?. I am a children's book author and creating many interactive AR quiz on body safety rules
Hello thanks for the tutorial I have a doubt if my question is in the form of audio how can I implemented this script?
@lp7161
2 жыл бұрын
Did you figure out?
My answers always get wrong. Can you help me?
@annisara_ma
Жыл бұрын
did you solve it already? please reply I have same problem here
QnA does not appear in quizmanager in unity How can this be?
@aqualix4662
3 жыл бұрын
i have the same
@rueditobler1827
3 жыл бұрын
@@aqualix4662 May be you forgot tis in the QuestionAndAnswer-Script: [System.Serializable ] (at the beginning of the script)
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
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... :((
@LegitSpartaN118
2 жыл бұрын
did you find a fix for this?
@zudla9959
2 жыл бұрын
just ignore the 0 in elements starts with 1 hope it helps
@sparksy1394
2 жыл бұрын
Same issue, any idea on how to fix?
@LegitSpartaN118
2 жыл бұрын
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
@jaymarkvergara4864
Жыл бұрын
@@zudla9959 how to fix the 0elements doesn't not show the question and answer
why all the result is wrong answer? even though it was the correct answer
hi, i'm trying to make the video exactly, but at 8:58 void SetAnswers() { for (int i=0;i
@marcusdavenport2156
2 жыл бұрын
Try using a upper case "L"
@dimagi7864
2 жыл бұрын
try " for (int i = 0; i < options.Length; i++)"
So u don't know any SOLID princeple? ( class name QuestionAndAnswer?, mabe better do class question and another class answer and the override ??)
Didn’t work
@TheGameGuy
3 жыл бұрын
Could you be more specific?
When I launch the game, the initial text remains but the first question does not appear. Can you help me please.
@thehustler2861
3 жыл бұрын
check the functions. U might made an error on syntax
12:44
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.
@ilhamhafiez5511
2 жыл бұрын
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
@syahmiasyraaf9965
2 жыл бұрын
@@ilhamhafiez5511 anjai jumpa kat sini HAHAHAHHAHA
@ilhamhafiez5511
2 жыл бұрын
@@syahmiasyraaf9965 CARI MASALAH ERROR BANG HHAHAHAHA
@littlemisswai
Жыл бұрын
It is 5 months later but I just want to thank you so much for this fix!
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.
@bental3066
2 жыл бұрын
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
Hhj
It is same as brackeys tutorial, even you copy his sentence
@TheGameGuy
3 жыл бұрын
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.
@Korean_celebrities_meetup
3 жыл бұрын
@@TheGameGuy oh that's right
not working
@asyikinjalil
3 жыл бұрын
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
@nurfartinah4534
3 жыл бұрын
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
@johnianiiespejo3826
3 жыл бұрын
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?
@azzamrashid3726
9 ай бұрын
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?)
@TheGameGuy
3 жыл бұрын
make sure to put "using UnityEngine.UI" at the top of the script
@brianfuerte9613
3 жыл бұрын
@@TheGameGuy I follow your code in the first part.
@renieldizon5313
2 жыл бұрын
@@TheGameGuy using the "using UnityEngine.UI" still not works for me. It only gave me a lot of errors sir
@firstnamelastname2971
Жыл бұрын
if ur using tmp then do TextMeshProUGUI instead of Text