Execute event after ConversationEnded in only one branch

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Zlus
Posts: 6
Joined: Tue Mar 03, 2020 3:59 am

Execute event after ConversationEnded in only one branch

Post by Zlus »

Hello everyone,

I'm currently trying to execute a method in a script after the conversation ended. However, the catch is that only one Outcome of the conversation should cause the execution.

Currently, the solution attempt is to use OnExecute() in the Events inspector field in the dialogue window at the last sequence of the conversation. However, the method is executed WHILE the sequence is active, not after the conversation.

Adding an empty sequence also doesn't work because it waits for the user click.

Did anyone have the same Problem and solve it?
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Execute event after ConversationEnded in only one branch

Post by Tony Li »

You could add an empty node and include the Continue() sequencer command in the Sequence so the player doesn't have to click.

Or you could set a variable in the two branches -- for example setting the Script fields in the 2 possible ending nodes like this:

lastChoice1.png
lastChoice1.png (5.67 KiB) Viewed 353 times
lastChoice2.png
lastChoice2.png (5.75 KiB) Viewed 353 times

And adding a Dialogue System Trigger set to On Conversation End that checks the variable:

lastChoiceEnd.png
lastChoiceEnd.png (35.13 KiB) Viewed 353 times

Or, if you don't want to use a Dialogue System Trigger, you can add an OnConversationEnd method to a script:

Code: Select all

void OnConversationEnd(Transform actor)
{
    if (DialogueLua.GetVariable("LastChoice").asInt == 2)
    {
        // do something
    }
}
Zlus
Posts: 6
Joined: Tue Mar 03, 2020 3:59 am

Re: Execute event after ConversationEnded in only one branch

Post by Zlus »

Hi,

thanks a lot! Everything worked!
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Execute event after ConversationEnded in only one branch

Post by Tony Li »

Glad to help! :-)
Post Reply