Сharacter change event

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
kostyandru
Posts: 3
Joined: Wed Nov 10, 2021 7:25 am

Сharacter change event

Post by kostyandru »

Is there an event in the system that is activated when changing the character?
User avatar
Tony Li
Posts: 22131
Joined: Thu Jul 18, 2013 1:27 pm

Re: Сharacter change event

Post by Tony Li »

Hi,

What do you mean by changing the character? If you mean when a different character speaks a line, you could use an OnConversationLine method, Example:

Code: Select all

private int lastSpeakerID;

void OnConversationStart(Transform actor) { lastSpeakerID = -1; }

void OnConversationLine(Subtitle subtitle)
{
    if (string.IsNullOrEmpty(subtitle.formattedText.text)) return;
    if (subtitle.speakerInfo.id != lastSpeakerID)
    {
        Debug.Log($"{subtitle.speakerInfo.Name} started speaking.");
        lastSpeakerID = subtitle.speakerInfo.id;
    }
}
Post Reply