Closing a conversation from a script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
EHG Mike Weicker
Posts: 8
Joined: Mon Jul 22, 2019 6:02 pm

Closing a conversation from a script

Post by EHG Mike Weicker »

Hi, I would like to close a conversation via script conditions. I'm wondering what the best way to do that is.

I know that I can make a direct reference to the DialogueSystemController and call StopConversation but I'm wondering if there is a way to reference that without doing some painful FindObjectOfType() call.

I'm trying to recreate the StopConversationIfTooFar script because I can't get that one to work so if I'm missing something there then I might be able to make that work. I put it on my main character and it doesn't close the conversations when you get too far.

Thanks,
Mike
User avatar
Tony Li
Posts: 21975
Joined: Thu Jul 18, 2013 1:27 pm

Re: Closing a conversation from a script

Post by Tony Li »

Hi,
EHG Mike Weicker wrote: Mon Jul 22, 2019 6:06 pmHi, I would like to close a conversation via script conditions. I'm wondering what the best way to do that is.
Use DialogueManager.StopConversation(). It's a static method. You don't need to find any components.
EHG Mike Weicker wrote: Mon Jul 22, 2019 6:06 pmI'm trying to recreate the StopConversationIfTooFar script because I can't get that one to work so if I'm missing something there then I might be able to make that work. I put it on my main character and it doesn't close the conversations when you get too far.
Are the participants assigned as you intend? If you temporarily set the Dialogue Manager's Other Settings > Debug Level to Info, it will log a line like this when starting a conversation:

Dialogue System: Starting conversation 'XXX' with actor=AAA and conversant=BBB.

If the StopConversationIfTooFar script is on AAA or BBB, then it will monitor the distance between them.

Similar functionality is built into the Dialogue System Trigger. It assumes that the main character (player) is assigned as the Dialogue System Trigger's Conversation Actor. It monitors the distance between the Conversation Actor and the Dialogue System Trigger.
EHG Mike Weicker
Posts: 8
Joined: Mon Jul 22, 2019 6:02 pm

Re: Closing a conversation from a script

Post by EHG Mike Weicker »

Thanks, I was hoping it would be that simple, I did try looking in the docs :)
User avatar
Tony Li
Posts: 21975
Joined: Thu Jul 18, 2013 1:27 pm

Re: Closing a conversation from a script

Post by Tony Li »

Happy to help!
EHG Mike Weicker
Posts: 8
Joined: Mon Jul 22, 2019 6:02 pm

Re: Closing a conversation from a script

Post by EHG Mike Weicker »

I figured out why I couldn't use that in the first place. We have another script called DialogueManager which was interfering with it but didn't cause an error.
User avatar
Tony Li
Posts: 21975
Joined: Thu Jul 18, 2013 1:27 pm

Re: Closing a conversation from a script

Post by Tony Li »

Got it. BTW, the Dialogue System's DialogueManager is in the namespace PixelCrushers.DialogueSystem. So if you ever need to disambiguate, you can specify PixelCrushers.DialogueSystem.DialogueManager.
Post Reply