Typewriter speed based on audio
Posted: Wed Sep 27, 2023 10:26 am
Hello Tony,
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:
In my custom Typewriter I set the charactersPerSecond before the StartTyping method :
But I think the typewriter starts typing before the entry sequence starts. Do you have an idea to set the typewriter speed based on the audio length?
Thank you,
Océane
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