How to change conversations dynamically with C# scripts?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Deadlybrunch
Posts: 6
Joined: Mon Jul 06, 2020 11:15 am

How to change conversations dynamically with C# scripts?

Post by Deadlybrunch »

Hello!
Thanks for help! I have a problem when using Dialogue System: how can I change conversations dynamically with C# scripts?
For example,I have a conversation with the title "TestConversation1/Start" and it is the default conversation, and I still have another conversation "NewConversation/Start". Sometimes I want to use the first conversation, and sometime I want change the current conversation to the second one. I've search the APIs but I find no such ways.
What I want is this: I have a button, when I clicked the button, the conversation start. But sometimes I need the first conversation start, sometimes the second one. How can I control it dynamically with C# scripts?Is the keywords the "Title" or the "ID"?
Hope for your answer,thanks!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to change conversations dynamically with C# scripts?

Post by Tony Li »

Hi,

In C#, you can use DialogueManager.StartConversation():

Code: Select all

using PixelCrushers.DialogueSystem;
...
if (//some condition//)
{
    DialogueManager.StartConversation("TestConversation1/Start", actorTransform, conversantTransform);
}
else
{
    DialogueManager.StartConversation("NewConversation/Start", actorTransform, conversantTransform);
}
If you're using Dialogue System Triggers, you can add two Dialogue System Triggers to the GameObject.
  • Configure the first one to start TestConversation1/Start. Set the Conditions, for example to require that a Dialogue System variable is a specific value (e.g., Variable["PlayTest1"] == true).
  • Configure the second Dialogue System Trigger to start NewConversation/Start. Set the Conditions differently, for example to require that the variable is a different value (e.g., Variable["PlayTest1"] == false).
Or you can always start the same conversation, and branch from there inside the conversation itself. You can link a conversation's node to another conversation. Links can cross conversations.
Deadlybrunch
Posts: 6
Joined: Mon Jul 06, 2020 11:15 am

Re: How to change conversations dynamically with C# scripts?

Post by Deadlybrunch »

Thank you very much! That will be help!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to change conversations dynamically with C# scripts?

Post by Tony Li »

Happy to help!
Post Reply