How to close a conversation by script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
rauljl1
Posts: 55
Joined: Fri Apr 15, 2022 7:40 pm

How to close a conversation by script

Post by rauljl1 »

Hi Tony.
Some of my conversations have an Scene Event methods/functions on execute them.
But, while the function is executed, the Dialogue panel is still showing.
How can I close the panel or finish the conversation just an instant after calling the Scene Event?
Thanks in advance!
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to close a conversation by script

Post by Tony Li »

Hi,

If the Scene Event is on the last dialogue entry node, the conversation will end as soon as that node's Sequence finishes. If you want the Sequence to end immediately, set it to: Continue()

If it's not on the last node and you want to force the conversation to stop anyway, set the Sequence to: StopConversion()
User avatar
rauljl1
Posts: 55
Joined: Fri Apr 15, 2022 7:40 pm

Re: How to close a conversation by script

Post by rauljl1 »

Yes, the scene event is on the last node. Is an option that the player can choose. Have two On Execute Scene Events.
The problem is when I click the option which contains it, the convarsation it doesn't end like others. The Dialogue panel is still showing.
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to close a conversation by script

Post by Tony Li »

Are there any errors or warnings in the Console window? If your Scene Event calls a method that runs into an error, it's possible that this might prevent the Dialogue System from continuing.

Otherwise, temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. When the Scene Event runs, look for this message in the Console:

Dialogue System: Conversation ending.

If you see that message, the conversation has ended. If you don't, then the conversation is still active.
User avatar
rauljl1
Posts: 55
Joined: Fri Apr 15, 2022 7:40 pm

Re: How to close a conversation by script

Post by rauljl1 »

Hi, Tony.
I have one more question.
I have a conversation with 4 possible answers.
each answer have other dialogue entry.
If the player doesn't respond within 10 seconds, how do I force the conversation to follow a specific dialogue entry?
I've already done the time thing.
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to close a conversation by script

Post by Tony Li »

Hi,

The easiest way is to:

1. Set the Dialogue Manager's Display Settings > Input Settings > Response Timeout to 10 and Response Timeout Action to Choose First Response.

2. Make the default response dialogue entry the first in the question node's Links To list.

Other options:
  • If you don't want to make the entry the first in the Links To list, there are other Response Timeout Actions.
  • If you don't want every player response menu to time out after 10 seconds, leave Response Timeout set to 0. Instead, use the SetTimeout() sequencer command.
User avatar
rauljl1
Posts: 55
Joined: Fri Apr 15, 2022 7:40 pm

Re: How to close a conversation by script

Post by rauljl1 »

It worked very well. But I have a problem now. I shuffle my answers, so not picking first or last doesn't work for me. What I can do?
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to close a conversation by script

Post by Tony Li »

You could set the Response Timeout Action to one of the other values (see ResponseTimeoutAction here). If you change it to Custom, assign a method to DialogueManager.customResponseTimeoutHandler. In this method, you can decide what to do. The list of responses is in DialogueManager.currentConversationState.pcResponses[]. You can call DialogueManager.standardDialogueUI.OnClick(Response) to choose a response, such as:

Code: Select all

DialogueManager.customResponseTimeoutHandler = ChooseFirstResponse;
...
void ChooseFirstResponse()
{
    DialogueManager.standardDialogueUI.OnClick(DialogueManager.currentConversationState.pcResponses[0]);
}
User avatar
rauljl1
Posts: 55
Joined: Fri Apr 15, 2022 7:40 pm

Re: How to close a conversation by script

Post by rauljl1 »

Works perfectly. Thanks!
Post Reply