Page 1 of 1

OnConversationStart from other scripts?

Posted: Fri Jun 25, 2021 7:08 pm
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?)

Re: OnConversationStart from other scripts?

Posted: Fri Jun 25, 2021 7:39 pm
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);
}