Page 1 of 1
After Dialogue Code
Posted: Sat Jun 05, 2021 8:23 pm
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.
Re: After Dialogue Code
Posted: Sat Jun 05, 2021 8:56 pm
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:
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.
Re: After Dialogue Code
Posted: Sun Jun 06, 2021 4:11 am
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.
Re: After Dialogue Code
Posted: Sun Jun 06, 2021 9:19 am
by Tony Li
Can you please post screenshots of your configuration?
Re: After Dialogue Code
Posted: Sun Jun 06, 2021 10:54 am
by junwi21
Re: After Dialogue Code
Posted: Sun Jun 06, 2021 2:14 pm
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
Re: After Dialogue Code
Posted: Mon Jun 07, 2021 2:28 am
by junwi21
Yes, the trigger is on one of the participants.
Re: After Dialogue Code
Posted: Mon Jun 07, 2021 8:35 am
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.
Re: After Dialogue Code
Posted: Mon Jun 07, 2021 9:37 am
by junwi21
Yes, I was able to find the problem w the log thanks.
Re: After Dialogue Code
Posted: Mon Jun 07, 2021 10:53 am
by Tony Li
Great! Thanks for letting me know.