I'd like the typewriter speed to be based on the length of the audio we play and the number of characters. Because depending on the language, or the content of the text, the speed might be quite different.
In my Entries I have a sequence with a custom AudioWait:
Code: Select all
public class SequencerCommandAudioWaitLength : SequencerCommandAudioWait
{
protected override void TryAudioClip(string audioClipName)
{
base.TryAudioClip(audioClipName);
if(currentClip!=null)
{
DialogueLua.SetVariable("voicelineLength", currentClip.length);
}
}
}
Code: Select all
public override void StartTyping(string text, int fromIndex = 0)
{
float audioLength = DialogueLua.GetVariable("voicelineLength").asFloat;
charactersPerSecond = textComponent.text.Length / audioLength;
base.StartTyping(text, fromIndex);
}
Thank you,
Océane