OnConversationStart from other scripts?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
mac
Posts: 81
Joined: Sat Aug 22, 2020 7:54 pm

OnConversationStart from other scripts?

Post by mac »

Hey Tony, so I have a script that should make characters in a conversation face each other when they start dialogue, and return to their original rotation when it ends, how can my external scripts know when a conversation starts and ends? (I think that's called a listener, so my scripts would have a listener for conversation starts and ends I guess?)
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: OnConversationStart from other scripts?

Post by Tony Li »

Hi,

If the script is on the Dialogue Manager or one of the primary participants (see Character GameObject Assignments), you can add a Dialogue System Events component or a script with OnConversationStart/OnConversationEnd script messages to it.

If the GameObject isn't one of the primary participants, you can hook into the equivalent C# events. Example:

Code: Select all

void OnEnable()
{
    DialogueManager.instance.conversationStarted += MyConversationStartedHandler;
}

void OnDisable()
{
    DialogueManager.instance.conversationStarted -= MyConversationStartedHandler;
}

void MyConversationStartedHandler(Transform actor)
{
    Debug.Log("Conversation started: " + DialogueManager.lastConversationStarted);
}
Post Reply