Page 1 of 1

How to change conversations dynamically with C# scripts?

Posted: Sat Oct 31, 2020 1:43 am
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!

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

Posted: Sat Oct 31, 2020 9:19 am
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.

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

Posted: Sat Oct 31, 2020 2:27 pm
by Deadlybrunch
Thank you very much! That will be help!

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

Posted: Sat Oct 31, 2020 2:40 pm
by Tony Li
Happy to help!