After Dialogue Code

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
junwi21
Posts: 35
Joined: Wed Jan 27, 2021 12:18 am

After Dialogue Code

Post by junwi21 »

How do I run code when a specific dialogue is shown but only after the player closes the dialgue?

I have it right now where the code runs when the npc says a certain thing.
It causes the npc to move to a certain position.

But I want it to happen when the player closes the dialogue - I don't want them to move while the dialgue box is still showing which happens now.
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: After Dialogue Code

Post by Tony Li »

Hi,

Here are two ways:

1. Add another node to the end of the conversation. In this node's Sequence field, use this command:

Code: Select all

SetDialoguePanel(false)
You can use other sequencer commands, or a Lua function, or scene event, etc., to move the character.

2. Or add a component that will move the character when the conversation ends. Some options for this component are:
  • Dialogue System Trigger: Add it to the NPC. Set it to OnConversationEnd. Use Add Action to add action(s) to move the character. You can also use the Conditions section to move the character only if certain conditions are true.
  • Dialogue System Events: Hook up a C# method to the OnConversationEnd() event.
  • Your own script: Add an OnConversationEnd method. You can use DialogueLua to check conditions or DialogueManager.lastConversationStarted to check which conversation last played.
junwi21
Posts: 35
Joined: Wed Jan 27, 2021 12:18 am

Re: After Dialogue Code

Post by junwi21 »

I tried to set an actor variable to the name of the npc in the dialogue then use the dialogue trigger on conversation end to check to see if the name matched up and if it did, run a function but it's not working.
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: After Dialogue Code

Post by Tony Li »

Can you please post screenshots of your configuration?
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: After Dialogue Code

Post by Tony Li »

Hi,

The "OnConversationEnd" message will only be sent to the Dialogue Manager and the conversation's two primary participants.

Make sure the GameObject that has the Dialogue System Trigger component is on the Dialogue Manager GameObject or one of the primary participants. The primary participants are usually assigned to the Dialogue System Trigger (OnUse) component's Conversation Actor and Conversation Conversant fields.

More info: Character GameObject Assignments
junwi21
Posts: 35
Joined: Wed Jan 27, 2021 12:18 am

Re: After Dialogue Code

Post by junwi21 »

Yes, the trigger is on one of the participants.
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: After Dialogue Code

Post by Tony Li »

You are welcome to send a reproduction project to tony (at) pixelcrushers.com for this and the other question about the typewriter. I can take a look directly. It might be faster.

Otherwise, temporarily set the Dialogue Manager's Other Settings > Debug Level to Info.

When the conversation starts, the Dialogue System will log a message like this to the Console window:

Dialogue System: Starting conversation 'Title' with actor=XXX and conversant=YYY

Make sure the GameObject with the Dialogue System Trigger (OnConversationEnd) is XXX or YYY.

When the conversation ends, inspect the Dialogue System Trigger. The Condition section will show '(Last Result: True)' or '(Last Result: False)'. If it is false, then the Actions will not run.
junwi21
Posts: 35
Joined: Wed Jan 27, 2021 12:18 am

Re: After Dialogue Code

Post by junwi21 »

Yes, I was able to find the problem w the log thanks.
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: After Dialogue Code

Post by Tony Li »

Great! Thanks for letting me know.
Post Reply