I am trying to set up a dialogue system in Unity where the player can have repeatable conversations with multiple choice options, and return to specific points within the conversation. I’d like to be able to:
Start in Conversation 1, where the player makes choices.
Hit a point in Conversation 1 where it can pause and be resumed later.
Switch to Conversation 2, make choices there.
Return to the exact spot they left in Conversation 1.
Decide whether to continue Conversation 2 or take other actions.
Here’s an example workflow:
Conversation 1 ➔ Player makes choices ➔ Reaches a node to pause ➔ Saves position in Conversation 1.
Conversation 2 ➔ Player makes choices ➔ Returns to saved position in Conversation 1.
Repeats as needed.
Current Code
I found some code from another post that mostly achieves what I want, but it’s not perfect. Here’s what I have so far:
Code: Select all
private string _lastConversationStarted;
private int _lastConversationID;
public void SwitchToConversationAction(string conversation)
{
_lastConversationStarted = DialogueManager.lastConversationStarted;
_lastConversationID = DialogueManager.currentConversationState.subtitle.dialogueEntry.id;
DialogueManager.StopConversation();
DialogueManager.StartConversation(conversation);
}
public void ContinueConversation()
{
DialogueManager.StopConversation();
DialogueManager.StartConversation(_lastConversationStarted, null, null, _lastConversationID);
}
The main issue is that when I attempt to switch back to a previously paused conversation, it does not return to the correct node. Here’s the workflow I’m experiencing:
SwitchToConversationAction from Conversation A ➔ Go to Conversation B ➔ Return to saved node in Conversation A with ContinueConversation.
SwitchToConversationAction again from Conversation A ➔ Go to Conversation B ➔ Attempt to return to Conversation A, but this time it resumes at the wrong node.
Does anyone have any suggestions on how I can resolve this? Is there another property I should be using instead?
Thank you in advance!