Conversation End, Pausing Convos with Timescale and calling C# Script Functions

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
2linescrossed
Posts: 31
Joined: Tue May 16, 2023 10:37 pm

Conversation End, Pausing Convos with Timescale and calling C# Script Functions

Post by 2linescrossed »

Hello, I've got a few brief questions here:

- If I want to wait until a conversation has finished playing, what's the best way of going about it? I know there's an OnConversationEnd function in the dialogue system, but I don't know how to hook it up to the most recently played conversation, for example. (More specifically, I want to set a popup active AFTER a conversation ends, without using the Sequence to set it active, since I think that's still within the conversation itself.)

- How do I pause mid-conversation when I set the game to timescale 0?

- More of a reminder, but how do I call C# Script functions mid-conversation again?
User avatar
Tony Li
Posts: 21049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Conversation End, Pausing Convos with Timescale and calling C# Script Functions

Post by Tony Li »

Hi,
2linescrossed wrote: Tue Dec 12, 2023 3:31 am- If I want to wait until a conversation has finished playing, what's the best way of going about it? I know there's an OnConversationEnd function in the dialogue system, but I don't know how to hook it up to the most recently played conversation, for example. (More specifically, I want to set a popup active AFTER a conversation ends, without using the Sequence to set it active, since I think that's still within the conversation itself.)
Here are some ways to do it:
  • Hook into the C# event DialogueManager.instance.conversationEnded:

    Code: Select all

    DialogueManager.instance.conversationEnded += OnConversationEnded;
    ...
    void OnConversationEnded(Transform actor)
    {
        DialogueManager.instance.conversationEnded -= OnConversationEnded;
        // (Do your thing here.)
    }
  • Or add a Dialogue System Events component to the Dialogue Manager or one of the participants, and configure the OnConversationEnd() event.
  • Or add a script with an OnConversationEnd(Transform actor) to the Dialogue Manager or one of the participants.
  • Or add a Dialogue System Trigger to the Dialogue Manager or one of the participants, and set its Trigger to OnConversationEnd.
In any of these techniques, you can check DialogueManager.lastConversationEnded to know which conversation just ended.
2linescrossed wrote: Tue Dec 12, 2023 3:31 am- How do I pause mid-conversation when I set the game to timescale 0?
See: How To: Pause Dialogue In Pause Menu
2linescrossed wrote: Tue Dec 12, 2023 3:31 am- More of a reminder, but how do I call C# Script functions mid-conversation again?
The best way is to register your C# function with Lua. Then call your C# function in a dialogue entry node's Script field (or Conditions field if you're checking a condition).
Post Reply