Page 1 of 1

Сharacter change event

Posted: Fri Jun 02, 2023 5:14 am
by kostyandru
Is there an event in the system that is activated when changing the character?

Re: Сharacter change event

Posted: Fri Jun 02, 2023 8:22 am
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;
    }
}