Quiz
Run a spoken quiz, game show or test in Unity with a Neocortex AI character as the host, for one player or several, using the Quiz Agent and a question set.
Team plan
Quizzes need a Team plan and at least one question set.
NeocortexQuizAgent lets one of your characters host a quiz, a game show or a spoken test. You write the questions in a question set on the web platform. Question order, retries, hints, judging and scoring happen on the server. Your game hands over what the player said and shows what comes back.
How a run works on the server is covered in Web API Quiz.

Setting up
- Add a
NeocortexQuizAgentto the host's GameObject - Pick the host in its Character dropdown and the set in its Question Set dropdown. Both lists come from your account.
- Optional: set Question Count (0 uses the set's own count) and Question Order (
SetDefault,InOrderorShuffled)

The host speaks in the character's voice. Turn off Speak Host Lines for a silent host. An AudioSource is added for the voice when you don't assign one. Add a NeocortexFaceAnimator on the host and its mouth follows each line.
For a quick text UI, add a NeocortexQuizUI with a chat panel, a text input and a thinking indicator. The input only shows while the host is waiting for an answer.
Running a quiz
using UnityEngine;
using Neocortex;
using Neocortex.Data;
public class QuizScene : MonoBehaviour
{
[SerializeField] private NeocortexQuizAgent quiz;
private void Start()
{
quiz.OnHostLine.AddListener(line => subtitles.Show(line.text));
quiz.OnQuestionChanged.AddListener(ShowQuestion);
quiz.OnUpcomingQuestion.AddListener(next => scenery.Preload(next.keyword));
quiz.OnLeaderboardChanged.AddListener(scoreboard.Show);
quiz.OnQuizFinished.AddListener(results.Show);
quiz.Begin();
}
private void ShowQuestion(QuizQuestion question)
{
questionLabel.text = question.questionText;
scenery.Show(question.keyword);
foreach (QuizOption option in question.options)
{
AddButton(option.text, () => quiz.Choose(option.id));
}
}
}Begin() starts the run. The host welcomes the player and asks the first question. After that your game only reports what the player did:
| Player did | Call |
|---|---|
| Tapped an option | Choose(optionId) |
| Spoke | Say(transcript) |
| Typed | Say(text, true) |
| Skipped, or your timer ran out | Pass() |
Hints, repeats and stopping are just words: Say("Can I have a hint?"). LastIntent tells you how the host read the last thing said, for example Hint or Repeat. A typed answer is judged as written, so a misspelling is not treated as a mishearing.
OnQuestionChanged fires as the host starts asking the question, so the scene changes on the right line. OnUpcomingQuestion gives the next question's keyword early, so you can load its scene while the host is still talking.
The question
QuizQuestion carries what the game may show, and nothing it may not: the answer, the rubric and the hint text stay on the server.
| Member | Description |
|---|---|
questionText | The question. |
type | "free_text", "multiple_choice" or "true_false". |
options | The choices to show, each with id and text. Empty for an open answer. |
IsChoice | True when the player picks from options. |
keyword | The author's name for the scene this question needs, such as SHOW_RED_APPLE. |
hasHint | Whether the player can ask for a clue. |
Voice answers
Open the microphone when the host expects something, transcribe the recording, and pass the text to Say():
private readonly ApiRequest api = new();
private void Start()
{
quiz.OnExpectingChanged.AddListener(expecting =>
{
if (expecting != QuizExpecting.Nothing) mic.StartMicrophone();
});
mic.OnAudioRecorded.AddListener(OnRecorded);
}
private async void OnRecorded(AudioClip clip)
{
string text = await api.RequestTranscription(quiz.characterID, clip);
if (string.IsNullOrWhiteSpace(text)) mic.StartMicrophone(); // nothing heard, listen again
else quiz.Say(text);
}Expecting is Answer for an attempt at the question, Confirmation for a yes or a no (usually to an offer of another try), and Nothing while the host is talking or the quiz is over.
Don't send an empty transcript with Say(""). An empty string is a deliberate pass, which means the player chose to skip.
Several players
Fill Participants in the inspector, or pass a roster to Begin(), and name the player on each answer:
quiz.Begin(new[]
{
new QuizParticipant { id = "anna", displayName = "Anna" },
new QuizParticipant { id = "ben", displayName = "Ben" },
});
quiz.ChooseAs("anna", optionId);
quiz.SayAs("ben", transcript);
quiz.PassAs("ben"); // Ben's timer ran outThe host waits until everyone has answered. OnPendingChanged and PendingParticipants track who is still to answer, and AnsweredParticipants who has. Timers are yours. The Quiz Show sample runs one to four players.
OnResult raises how each player's answer was judged (participantId, verdict, score), and OnLeaderboardChanged the standings (participantId, displayName, totalScore, rank). Players on the same score share a rank.
Input while the host is busy
While a turn is in flight, IsBusy is true and OnBusyChanged fires. With Queue Input While Busy on (the default), what the player says is held and sent once the host is ready. Only the newest answer per player is kept, and an answer older than Max Pending Input Age (default 4 seconds) is dropped.
OnInputDropped(text, reason) tells you when something never reached the host:
| Reason | Why |
|---|---|
Superseded | The player said something newer, which is sent instead. |
Expired | It waited too long to still answer what the host asked. |
Finished | The run has already ended. |
NoSession | The quiz has not started yet. |
Failed | The turn it would have gone on failed. |
Busy | The host was busy and Queue Input While Busy is off. |
Errors and recovery
When a turn fails, the agent drops held input and calls Resync() by itself, which reads the run back from the server and reopens input where it left off. Call Resync() yourself after a lost connection.
When your team has run out of usage, or a usage limit is reached, the agent raises OnCreditsExhausted(code) and keeps input closed until you call Resync().
Abort() silences the host and abandons whatever is in flight, without ending the run on the server.
The full list of members and events is in the API Reference.
Group Chat
Put several AI characters in one conversation in Unity with the Neocortex Group Director, each with its own voice, joining, leaving and talking to each other.
API Reference
C# reference for the Neocortex Unity SDK 0.8 with AI NPC agents, chat lines, actions, group chat, quizzes, usage, voice, lip sync and errors in Unity.