Page 1 of 1
How to stop conversation with script
Posted: Thu Sep 29, 2022 7:37 am
by SBSun
I am trying to implement a script so that I can start a conversation when I want, move on to the next dialog entry when I want, and forcefully end the conversation when I want.
The OnUse() function was used to start a conversation when desired, and the function to move on to the next Dialogue Entry was implemented with the Sequence's WaitForMessage() function.
But I don't know how to force end the conversation.
1. I have multiple Enemys in my game, and each Enemy can talk to itself or have a conversation. I would like to know how I can force quit only the Conversations I want.
2. I wonder if there is a variable that can check if Conversatio is in progress.
Re: How to stop conversation with script
Posted: Thu Sep 29, 2022 8:14 am
by Tony Li
Hi,
To start a conversation from a script (if you prefer that to OnUse()), use
DialogueManager.StartConversation().
To advance a conversation, call DialogueManager.standardDialogueUI.OnContinue() to simulate a continue button click, or use DialogueManager.conversationController.GotoState() to manually jump to a specific dialogue entry. For GotoState(), see
this example.
To check if a conversation is active, check
DialogueManager.isConversationActive.
To stop a conversation, use
DialogueManager.StopConversation() or StopAllConversations().
If you run simultaneous conversations, each conversation will have an ActiveConversationRecord. You can access them through
DialogueManager.instance.activeConverrsations. To stop a specific conversation, call its conversationController.Close() method.
Re: How to stop conversation with script
Posted: Thu Sep 29, 2022 8:34 am
by SBSun
Thank you for answer!
Could it be that the sequence of the Entry cannot be set as a script at runtime?
I tried running the code to change the sequence as shown in the picture, but it didn't work.
Re: How to stop conversation with script
Posted: Thu Sep 29, 2022 9:14 am
by SBSun
I changed it to DialogueManager.StartConversation() and tried it, but is DialogueManager.StartConversation() only output to Dialogue UI of Dialogue System Controller?
Enemy's self-talk wants to output the UI to the Custom Subtitle Panel set in Dialogue Actor.
Re: How to stop conversation with script
Posted: Thu Sep 29, 2022 9:20 am
by Tony Li
You can do that before starting the conversation. But once you've started the conversation it's too late because the original Sequence will already be cached in a Subtitle object. You can use an OnConversationLine() method to modify the Subtitle object's sequence property.
Re: How to stop conversation with script
Posted: Thu Sep 29, 2022 9:22 am
by Tony Li
SBSun wrote: ↑Thu Sep 29, 2022 9:14 amI changed it to DialogueManager.StartConversation() and tried it, but is DialogueManager.StartConversation() only output to Dialogue UI of Dialogue System Controller?
Enemy's self-talk wants to output the UI to the Custom Subtitle Panel set in Dialogue Actor.
Provide the enemy GameObject to DialogueManager.StartConversation(). Example:
Code: Select all
DialogueManager.StartConversation("Self Talk", playerTransform, enemyTransform);
(This assumes the enemy is the conversation's Conversation Conversant.)
Re: How to stop conversation with script
Posted: Thu Sep 29, 2022 9:57 am
by SBSun
Thank you for answer! It really helped a lot!
However, as an experiment, I tested it with two Enemy, and the same StartConversation was applied, but only one of the objects started the conversation. Can't two or more conversations run at the same time?
Re: How to stop conversation with script
Posted: Thu Sep 29, 2022 10:32 am
by Tony Li
Hi,
You must tick the Dialogue Manager GameObject's Other Settings > Allow Simultaneous Conversations.
In addition, add an Override Dialogue UI component to each enemy, and assign the Basic Standard Dialogue UI prefab. The enemy will use its own bubble panel, but it needs to the Basic Standard Dialogue UI's StandardDialogueUI script to control its operation.