hey, I’m a new game dev and I’ve been following this brackeys tutorial
everything works fine except for some reason the button i have to start the dialogue skips straight to the final sentence and I’m not sure how to make it go in order, from one sentence to the next. this is the code below
would be great if anybody knows how to fix this.
public class dialogueManager : MonoBehaviour
{
public TextMeshProUGUI nametext;
public TextMeshProUGUI dialoguetext;
private Queue<string> sentances;
// Start is called before the first frame update
void Start()
{
sentances = new Queue <string>();
}
public void startdialogue (dialogue Dialogue)
{
nametext.text = Dialogue.name;
sentances.Clear();
foreach (string sentance in Dialogue.sentances)
{
sentances.Enqueue(sentance);
desplaynextSentance();
}
}
public void desplaynextSentance()
{
if (sentances.Count == 0)
{
EndDialogue();
return;
}
string sentance = sentances.Dequeue();
dialoguetext.text = sentance;
}
public void EndDialogue()
{
Debug.Log("end of conversation");
}
}