Hello I have a question, I'm sure it's possible but I can't find it :
let's say I have a dialoge that goes :
"Hello, my name is...UNITY"
I would like to trigger a sequence commande exactly at a certain point for example
"Hello, my name is...[CHANGE CAMERA]UNITY"
I now I could do a wait, but is there a precise way to control sequence in the middle of dialogue text ?
How to trigger a sequence command in the middle of a dialogue text ?
How to trigger a sequence command in the middle of a dialogue text ?
Currently working on ->Squeakross: Home Squeak Home<- Using Dialogue System Save System and other features.
Previous game made with Dialogue system ->The Spirit and The mouse<-
Previous game made with Dialogue system ->The Spirit and The mouse<-
Re: How to trigger a sequence command in the middle of a dialogue text ?
Hi,
You could add a custom tag to the text, like:
"Hello, my name is... <camera>UNITY"
and set the Sequence to something like:
Then add little script to the Dialogue Manager that handles that tag and sends the sequencer message "MoveCamera" at the appropriate time. The script can use an OnConversationLine method that extracts the tag and adjusts the Sequence to send the sequencer message. Something like:
(Note: I just typed this into the reply. It might have typos.)
(EDIT: Changed the way the duration is computed.)
You could add a custom tag to the text, like:
"Hello, my name is... <camera>UNITY"
and set the Sequence to something like:
Code: Select all
{{default}};
Camera(Closeup)@Message(MoveCamera)
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class CustomDialogueTagHandler : MonoBehaviour
{
public float typewriterCharsPerSec = 50;
void OnConversationLine(Subtitle subtitle)
{
int tagPosition = subtitle.formattedText.text.IndexOf("<camera>");
if (tagPosition == -1) return; // If no tag, we're done.
// Remove the tag from the text:
subtitle.formattedText.text = subtitle.formattedText.text.Remove(tagPosition, "<camera>".Length);
// Add a sequencer command to send "MoveCamera" at the right time:
string textBeforeTag = subtitle.formattedText.text.Substring(0, tagPosition);
float duration = textBeforeTag.Length / typewriterCharsPerSec;
if (string.IsNullOrEmpty(subtitle.sequence)) subtitle.sequence = "{{default}}";
subtitle.sequence = "Delay(" + duration + ")->Message(MoveCamera); " + subtitle.sequence;
}
}
(EDIT: Changed the way the duration is computed.)