how to know when the dialogue change the node.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
alfonso
Posts: 104
Joined: Mon Jul 13, 2015 6:31 am

how to know when the dialogue change the node.

Post by alfonso »

Hi Tony :)

Is possible to know when the dialogue change to the next node? i would like to add a custom sequence to play a animator in a node and when the node change go back to the default or the other animator state.

i know if i put in the next node the AnimatorPlay to a idleAnimator works but is something i need to do with a lot of npc and a little automation will be great :)

is any way to do this?


Thanks for the help :)
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: how to know when the dialogue change the node.

Post by Tony Li »

Hi,

Here are some ways you can do this. You can choose the one that works best for your situation.

1. Use the sequencer ->Message() and @Message syntax. This example uses SALSA for lipsync:

Code: Select all

AnimatorTrigger(speaking);
SALSA(entrytag)->Message(Done);
AnimatorTrigger(idle)@Message(Done)
The sequence above sets the Animator's "speaking" trigger and plays a lipsynced audio clip through SALSA. The audio clip is defined by the dialogue entry's unique entrytag for automation, so you could use this as the Dialogue Manager's Default Sequence. When the SALSA() command is done, it sends the message "Done" to the sequencer. The last command waits until it receives the message "Done", and then it sets the Animator's "idle" trigger.


2. Use a Response Menu Sequence field. From the manual: This is "an optional field that specifies a sequence that will play in the background after the dialogue entry's text has been delivered and the response menu is being shown." You can add Response Menu Sequence to the dialogue database template to make it apply to all dialogue entries.


3. Write a script with an OnConversationLine method. Add it to the Dialogue Manager. For example:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
public class IdleBeforeLine : MonoBehaviour {

    public void OnConversationLine(Subtitle subtitle) {
        // Idle before speaking the next line:
        subtitle.speakerInfo.transform.GetComponent<Animator>().SetTrigger("idle");
    }
}
4. Write a subclass of your dialogue UI. Override HideSubtitle:

Code: Select all

public class MyDialogueUI : UnityUIDialogueUI {

    public override void HideSubtitle(Subtitle subtitle) {
        // Idle when done speaking the line:
        subtitle.speakerInfo.transform.GetComponent<Animator>().SetTrigger("idle");
    }
}
Post Reply