On Conversation Line by Actor

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lordzeon
Posts: 12
Joined: Mon Feb 26, 2024 5:06 pm

On Conversation Line by Actor

Post 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.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: On Conversation Line by Actor

Post 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");
    }
}
lordzeon
Posts: 12
Joined: Mon Feb 26, 2024 5:06 pm

Re: On Conversation Line by Actor

Post 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?
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: On Conversation Line by Actor

Post 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.
Post Reply