How can I specify starting dialogue after a conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
hoangvm2307
Posts: 10
Joined: Thu Feb 29, 2024 10:11 am

How can I specify starting dialogue after a conversation

Post by hoangvm2307 »

For example, I talk to an NPC at node 4, then I leave, and when I come back, I want to continue at node 5.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: How can I specify starting dialogue after a conversation

Post by Tony Li »

Hi,

Here are two options:

1. Use a dialogue database variable to record the player's position. Then use Conditions to go to that entry. This works best if you want to record specific parts in the conversation. Example:

rememberVariable.png
rememberVariable.png (25.11 KiB) Viewed 365 times

2. Or record the current dialogue entry ID in a C# script and use DialogueManager.StartConversation() to start the conversation again at the next entry. Example:

Code: Select all

int nextEntryID = -1;

void OnConversationLine(Subtitle subtitle)
{
    var npcResponses = DialogueManager.currentConversationState.npcResponses;
    nextEntryID = (npcResponses.Length > 0) ? npcResponses[0] : -1;
}

public void ResumeConversation()
{
    DialogueManager.StartConversation("conversation-title", playerTransform, npcTransform, nextEntryID);
}
hoangvm2307
Posts: 10
Joined: Thu Feb 29, 2024 10:11 am

Re: How can I specify starting dialogue after a conversation

Post by hoangvm2307 »

Thank you Tony, very quick and informative reply :D :D
hoangvm2307
Posts: 10
Joined: Thu Feb 29, 2024 10:11 am

Re: How can I specify starting dialogue after a conversation

Post by hoangvm2307 »

Is it the same solution to this case

an NPC has 2 conversations, I named it A and B.
  • The conversation A will be triggered if I click that NPC
  • The conversation B will be triggered if the player touch him (by collider)
Or I have to use another component "Dialogue System Trigger" (In this case 2 Dialogue System Trigger are used in this NPC)
Last edited by hoangvm2307 on Fri Mar 01, 2024 11:01 am, edited 1 time in total.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: How can I specify starting dialogue after a conversation

Post by Tony Li »

Hi,

You can use two separate Dialogue System Triggers on the same NPC.
  • Set conversation A's trigger to OnUse and add a Usable component and a collider to the NPC. Configure a Selector component on the player/camera to use mouse position, and set the Use Key to Mouse 0.
  • Set conversation B's trigger to OnCollisionEnter. Make sure the player and NPC are on layers that will register collisions.
hoangvm2307
Posts: 10
Joined: Thu Feb 29, 2024 10:11 am

Re: How can I specify starting dialogue after a conversation

Post by hoangvm2307 »

Thank you for your help :D :D
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: How can I specify starting dialogue after a conversation

Post by Tony Li »

Happy to help!
Post Reply