Hello,
First time using the forum so bear with me!
I am trying to randomize the response menu when I display a set of dialogue options and can't seem to figure out how to do it.
I want to do this so that if the player has played through the game once he would not be able to select the dialog in the same position to get the correct response again.
Ex
First play through
1. Dialog#1
2.Dialog#2
3.Dialog#3
Second playthrough
First play through
1. Dialog#2
2.Dialog#1
3.Dialog#3
Thanks!
Randomize Response Positions
Re: Randomize Response Positions
Hi,
Welcome to the forum!
You can add this script to your Dialogue Manager. It will shuffle the response menu:
ShuffleResponses.cs
Here's an example scene that contains the script: QuizExample_2017-05-21.unitypackage
It also contains an example of randomly generating numbers for a math quiz.
Welcome to the forum!
You can add this script to your Dialogue Manager. It will shuffle the response menu:
ShuffleResponses.cs
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
// Add this script to the Dialogue Manager or one of the conversation participants
// to shuffle the responses that will be shown in the player response menu.
public class ShuffleResponses : MonoBehaviour
{
void OnConversationResponseMenu(Response[] responses)
{
for (int t = 0; t < responses.Length; t++)
{
var temp = responses[t];
int r = Random.Range(t, responses.Length);
responses[t] = responses[r];
responses[r] = temp;
}
}
}
It also contains an example of randomly generating numbers for a math quiz.
-
- Posts: 2
- Joined: Mon Jan 22, 2018 2:02 am
Re: Randomize Response Positions
Thank you so much that worked great!
Re: Randomize Response Positions
Great! Happy to help!