Page 1 of 1
Closing a conversation from a script
Posted: Mon Jul 22, 2019 6:06 pm
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
Re: Closing a conversation from a script
Posted: Mon Jul 22, 2019 8:25 pm
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.
Re: Closing a conversation from a script
Posted: Tue Jul 23, 2019 4:10 am
by EHG Mike Weicker
Thanks, I was hoping it would be that simple, I did try looking in the docs
Re: Closing a conversation from a script
Posted: Tue Jul 23, 2019 8:37 am
by Tony Li
Happy to help!
Re: Closing a conversation from a script
Posted: Tue Jul 23, 2019 11:07 am
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.
Re: Closing a conversation from a script
Posted: Tue Jul 23, 2019 11:40 am
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.