Page 1 of 1

On Conversation Line by Actor

Posted: Wed Mar 13, 2024 8:59 pm
by lordzeon
Hi, im adding some animations for when an Actor say a Line, i don't want to do this on the sequence but Generic to each actor, so i added Dialogue System Events and played the animation with the Event On Conversation Line, but it work to any conversation Line and not just the associated actor as i expected, there is any other way to do this but only for the actor talking, my Player deliver the line too but even with hidden responses, i would like to play an animation on response choose too.

Re: On Conversation Line by Actor

Posted: Wed Mar 13, 2024 10:18 pm
by Tony Li
Hi,

If you're already scripting, you can omit the Dialogue System Events component and write a script with an OnConversationLine(Subtitle) method. This method is called on the Dialogue Manager GameObject, the conversation actor, and the conversation conversant.

For example, you can put it on the actors' GameObjects:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    if (subtitle.speaker.transform == this.transform)
    {
        // This actor is speaking this line.
        animator.Play("Talking");
    }
}

Re: On Conversation Line by Actor

Posted: Wed Mar 13, 2024 11:28 pm
by lordzeon
Great, this work. but when player choose an option, because the response is not shown as dialogue, player and NPC animate at the same time, there is any way to detect if the line is a selected response or a normal dialogue line?

Re: On Conversation Line by Actor

Posted: Thu Mar 14, 2024 8:04 am
by Tony Li
Hi,

You can check if subtitle.speakerInfo.isPlayer is true. If so, I recommend using a sequence to play the animation because this will make the conversation wait. Example:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    if (subtitle.speaker.transform == this.transform)
    {
        // This actor is speaking this line.
        if (subtitle.speakerInfo.isPlayer)
        {
            subtitle.sequence = "AnimatorPlayWait(Talking)";
        }
        else
        {
            animator.Play("Talking");
        }
    }
}
Also, if you want the player's lines to appear as subtitles after selecting from a response menu, tick the Dialogue Manager's Display Settings > Subtitle Settings > Show PC Subtitles During Line and UNtick Skip PC Subtitle After Response Menu.