Page 1 of 1

how to know when the dialogue change the node.

Posted: Thu Jul 30, 2015 10:47 am
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 :)

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

Posted: Thu Jul 30, 2015 8:53 pm
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");
    }
}