How to stop conversation with script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
SBSun
Posts: 46
Joined: Thu Sep 08, 2022 6:39 pm

How to stop conversation with script

Post 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.
Attachments
캡처.PNG
캡처.PNG (1.42 KiB) Viewed 1079 times
2.PNG
2.PNG (75.32 KiB) Viewed 1079 times
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to stop conversation with script

Post 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.
SBSun
Posts: 46
Joined: Thu Sep 08, 2022 6:39 pm

Re: How to stop conversation with script

Post 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.
Attachments
캡처.PNG
캡처.PNG (1.85 KiB) Viewed 1075 times
SBSun
Posts: 46
Joined: Thu Sep 08, 2022 6:39 pm

Re: How to stop conversation with script

Post 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.
Attachments
2.PNG
2.PNG (74.27 KiB) Viewed 1073 times
1.PNG
1.PNG (34.75 KiB) Viewed 1073 times
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to stop conversation with script

Post 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.
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to stop conversation with script

Post 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.)
SBSun
Posts: 46
Joined: Thu Sep 08, 2022 6:39 pm

Re: How to stop conversation with script

Post 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?
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to stop conversation with script

Post 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.
Post Reply