Best way to trigger a line of dialogue through code?
Best way to trigger a line of dialogue through code?
So here's the scenario. The player comes to a point in the conversation where they're asked if they know how to play poker. There's a face down card and if the player clicks on it I'd like that to count as a response and trigger a dialogue tree inside the current conversation.
Re: Best way to trigger a line of dialogue through code?
Hi,
Here are two options:
1. Set up your card to call the dialogue UI's "OnClick" method. You'll need to pass a Response object. For example:
2. Or set up your card to cancel the current conversation (DialogueManager.StopConversation) and then either restart it at a specific dialogue entry (DialogueManager.StartConversation) or set a Lua variable and restart it from the beginning and branch differently based on that Lua variable. For example:
Here are two options:
1. Set up your card to call the dialogue UI's "OnClick" method. You'll need to pass a Response object. For example:
Code: Select all
void OnMouseDown() {
var formattedText = FormattedText.Parse("This is the response text.", DialogueManager.MasterDatabase.emphasisSettings);
var dialogueEntry = DialogueManager.MasterDatabase.GetDialogueEntry(conversationID, dialogueEntryID);
var response = new Response(formattedText, dialogueEntry);
var dialogueUI = FindObjectOfType<UnityUIDialogueUI>();
dialogueUI.OnClick(response);
}
Code: Select all
void OnMouseDown() {
DialogueManager.StopConversation();
DialogueLua.SetVariable("clickedCard", true);
DialogueManager.StartConversation("My Conversation", actor, conversant);
}
Re: Best way to trigger a line of dialogue through code?
Awesome! That worked great!
Re: Best way to trigger a line of dialogue through code?
Great! Glad I could help.