problem with quiz game
Hello everyone i am following the unity official quiz game tutorials for making a quiz game. no problem with any of the point. but have a question on it.... how can i add multiple rounds in the game so that each round has different questions.. please help...i really need help...thanks
Answer by Pengocat · Jan 29, 2017 at 04:39 PM
I guess you are referring to this tutorial? Live Session: Quiz Game 1 My first thought would be to shuffle the array allRoundData
in the DataController script in it's Start Method. To get an idea of how to shuffle an array you could have a look at this other answer. Shuffle objects in object array randomly in c#
Answer by jzlow132 · Oct 07, 2018 at 03:07 PM
Just going through this and kinda figured this out. not sure if you still need this. but might help someone in the future. Its still not polished as im also in the midst of making this into what i want but..
The concept is to change up the value allRoundData[] in DataController.cs and changing it when its done.
so what i did was. DataController.cs
//create new variable
private int roundnum;
void Start ()
{
roundnum = 0 // set this to 0 at start
}
public RoundData GetCurrentRoundData()
{
return allRoundData [roundnum];
}
//to level up when a round ends
public void LevelUp()
{
roundnum++;
}
Then in GameController.cs add this method to update the allRoundData[]
public void NextRound()
{
dataController.LevelUp();
dataController = FindObjectOfType<DataController>();
currentRoundData = dataController.GetCurrentRoundData();
questionPool = currentRoundData.questions;
timeRemaining = currentRoundData.timeLimitInSeconds;
UpdateTimeRemainingDisplay();
playerScore = 0;
questionIndex = 0;
ShowQuestion();
isRoundActive = true;
}
The main thing is to play around with your allRoundData[] array. might not be a super clean code, im just learning unity and c# too.
Your answer
![](https://koobas.hobune.stream/wayback/20220612105808im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Cant drag the Text object to Score Label in UI script 0 Answers
2d roguelike tutorial board manager issues 2 Answers
Tanks Tutorial - dust trails not emitted on MovePosition 4 Answers
Tutorial problem 0 Answers