Page 1 of 1
Conversation End, Pausing Convos with Timescale and calling C# Script Functions
Posted: Tue Dec 12, 2023 3:31 am
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?
Re: Conversation End, Pausing Convos with Timescale and calling C# Script Functions
Posted: Tue Dec 12, 2023 8:46 am
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).
Re: Conversation End, Pausing Convos with Timescale and calling C# Script Functions
Posted: Sun Jul 14, 2024 7:15 am
by 2linescrossed
Hey, thanks for bearing with me as I bring up this old thread - but I wanted to expand on this question:
The previous solutions would work, but what if I just wanted to do a single OnConversationEnd function that doesn't get added to every OnConversationEnd for the conversation manager?
For example - lets say I want a character to wish the player well before they leave the scene, triggering the scene change once the convo is done. If I make a function in a script managing the scene that hooks into the DialogueManager's function, wouldn't that mean the effect gets applied to every single ConversationEnd?
Re: Conversation End, Pausing Convos with Timescale and calling C# Script Functions
Posted: Sun Jul 14, 2024 9:21 am
by Tony Li
Hi,
Yes, that's correct. Some ideas:
- You could add a script or Dialogue System Events component to one of the participants (e.g., the NPC that the player is talking to) and configure its OnConversationEnd to do the work. This OnConversationEnd will only run when the participant is involved in the conversation.
- Or you could trigger the scene change in an empty node at the end of the conversation. For example, add a node to the end of the conversation with blank Dialogue Text and a Sequence set to something like:
Code: Select all
required LoadLevel("New Scene Name");
Continue()