Please can anyone recommend a stress free and dependable way of shuffling the position of dialogue options in AC? I don't want the options to appear at the same place every time so the player actually has to read through the options to select the right one. (I hooked up the dialogue menu using Unity's UI) I have spent an inordinate amount of time trying to get the Fisher Yates shuffle (piped through a function created in a dedicated script which is then called when required through an AC action list) to work, however, it does not return entirely unique positions every time, sometimes the positions overlap, sometimes, the last index stays fixed to the same spot no matter how many times you shuffle the options. From what I've seen so far, the Fisher Yates Shuffle, has it's quirks and those quirks are not aligning too well with what I need.
I've tried to think if there was a way I could hook up AC's variable: Check Random Number, but it doesn't seem possible without a monstrously sized action list editor with complicated nodes.
Here's the function I've been struggling with, this is the closest I got to something stable, I've tweaked it a gazillion times with the issues referred to above not going away:
public void ShuffleBtns()
{
a = new int[dialogueMenuBtns.Length];
foreach (GameObject y in dialogueMenuBtns)
{
for (int x = 0; x < dialogueMenuBtns.Length - 1; x++)
{
a[x] = x;
}
}
for (int i = 0; i < a.Length - 1; i++)
{
foreach (GameObject z in dialogueMenuBtns)
{
int randomIndex = Random.Range(i, a.Length - 1);
int temp = a[i];
a[i] = a[randomIndex];
a[randomIndex] = temp;
}
dialogueMenuBtns[a[i]].transform.position = dialogueBtnLocations[i].transform.position;
}
}
Comments
Are you overriding the Conversation's options in a single ActionList, or having each option run its own DialogOption ActionList. If the latter, you could instead use the randomisation to re-order the Conversation's options List, as opposed to re-positioning the options - which may solve the overlapping problem.