Page 1 of 1
How can I specify starting dialogue after a conversation
Posted: Fri Mar 01, 2024 8:43 am
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.
Re: How can I specify starting dialogue after a conversation
Posted: Fri Mar 01, 2024 10:37 am
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 (25.11 KiB) Viewed 362 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);
}
Re: How can I specify starting dialogue after a conversation
Posted: Fri Mar 01, 2024 10:42 am
by hoangvm2307
Thank you Tony, very quick and informative reply
Re: How can I specify starting dialogue after a conversation
Posted: Fri Mar 01, 2024 11:00 am
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)
Re: How can I specify starting dialogue after a conversation
Posted: Fri Mar 01, 2024 3:48 pm
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.
Re: How can I specify starting dialogue after a conversation
Posted: Fri Mar 01, 2024 10:08 pm
by hoangvm2307
Thank you for your help
Re: How can I specify starting dialogue after a conversation
Posted: Fri Mar 01, 2024 10:12 pm
by Tony Li
Happy to help!