OnConversationStart from other scripts?
OnConversationStart from other scripts?
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?
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:
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);
}