Detect conversation 'finishing' versus conversation 'cancelled'?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Jamez0r
Posts: 59
Joined: Fri Nov 20, 2020 8:18 pm

Detect conversation 'finishing' versus conversation 'cancelled'?

Post by Jamez0r »

Hi Tony!

I have an NPC that you talk to, who should give you an item if you fully complete his conversation. I have a sensor set up such that if you walk away from the NPC mid-conversation, it will stop/cancel the conversation.

Are there any callbacks that I could use, where I could know that the player fully completed the NPCs conversation, so that I can give the item to the player? With the "Dialogue System Events" component, the "On Conversation Ended" callback gets called even if the conversation is "cancelled".

If there isn't a callback type of way to know if the conversation was fully completed, would there be a way to do this via Lua Script on a conversation-node? I would need to give the item to the player *after* they have pressed the continue button on the final node (aka after the conversation has finished).

Thanks for the help!!
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: Detect conversation 'finishing' versus conversation 'cancelled'?

Post by Tony Li »

Hi,

You could add a node after the "final" node that doesn't have any Dialogue Text. Set its Sequence to Continue(). Use a Lua function in the Script field to give the item. (You can register your own C# method with Lua and then call this method in the Script field.)

Or you could set a variable in the final node. Add another Dialogue System Trigger set to OnConversationEnd to the NPC. Set this Dialogue System Trigger's Conditions > Lua Conditions to check the variable value. Set Actions > OnExecute() UnityEvent (or some other action) to give the item.
Jamez0r
Posts: 59
Joined: Fri Nov 20, 2020 8:18 pm

Re: Detect conversation 'finishing' versus conversation 'cancelled'?

Post by Jamez0r »

Thanks Tony! I think the first method will work great :D
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: Detect conversation 'finishing' versus conversation 'cancelled'?

Post by Tony Li »

Great! Glad to help.
Post Reply