Page 1 of 1

Simple way to disable all audio in the Dialogue System?

Posted: Fri Oct 29, 2021 2:31 am
by datchcole
I want to give the player the option to disable the voice acting audio if they wanted in my options menu. I was wondering if there was a simple way to do so? Thanks for any info.

Re: Simple way to disable all audio in the Dialogue System?

Posted: Fri Oct 29, 2021 9:01 am
by Tony Li
Hi,

If the only audio that you play through the Dialogue System's sequencer commands is voice acting, then you can set a Dialogue System variable named "Mute" to true. If "Mute" is true, sequencer commands will not play audio.

You can set the variable in C#:

Code: Select all

DialogueLua.SetVariable("Mute", true);
Or in Lua code (e.g., dialogue entry's Script field):

Code: Select all

Variable["Mute"] = true
If you use sequencer commands to play other audio, you'll have to do something different. The easiest way is to use a {{shortcut}}. For example, create a shortcut named {{voiceover}} and use it in your dialogue entries' Sequence fields.

If voice acting is enabled, set {{voiceover}} to something like: AudioWait(entrytag)

If voice acting is disabled, set {{voiceover}} to: None()

You can set the shortcut using C#:

Code: Select all

Sequencer.RegisterShortcut("voiceover", "AudioWait(entrytag)");
or using a SequencerShortcuts component.

Re: Simple way to disable all audio in the Dialogue System?

Posted: Fri Oct 29, 2021 5:39 pm
by datchcole
Ah that makes sense. Thank you. I am using the sequences only for voice acting audio. I know how to use variables to control the dialogue tree, but how do I do a sort of:

if(mute==true){
//don't run AudioWait();
}


I still want it to go through the dialogue conversation, just text only. I can set the variable 'mute' in script no issue, but how do I have only the sequence code rely on the variable condition? Can I do it within the dialogue entry itself?

Re: Simple way to disable all audio in the Dialogue System?

Posted: Fri Oct 29, 2021 6:35 pm
by Tony Li
If you set the "Mute" variable true (using either of the ways I described above), AudioWait() will still wait for the duration of the audio clip; it just won't play the clip.

If you don't want to do that, you can use the other option -- the {{shortcut}}. For example:
  • If voice acting is enabled, set {{voiceover}} to: AudioWait(entrytag)
  • If voice acting is disabled, set {{voiceover}} to: Delay({{end}})
Then use {{voiceover}} in your Dialogue Manager's Default Sequence. If you've disabled voice acting, each line will wait for a duration based on Subtitle Settings > Subtitle Chars Per Second and Min Subtitle Seconds, which are based on the text length.

Re: Simple way to disable all audio in the Dialogue System?

Posted: Sat Oct 30, 2021 12:52 am
by datchcole
Hello, sorry I'm still missing something here. How do I specifically make it only skip the sequence commands? I can create and set the variable, but how do I set the condition that mute has to be true without skipping the dialogue entry as well? Like where would I set that? Somehow within the 'Sequence' field? I can't use the 'Conditions' field because it would skip the text?

Re: Simple way to disable all audio in the Dialogue System?

Posted: Sat Oct 30, 2021 8:28 am
by Tony Li
Hi,

If I understand you correctly, you won't want to skip the sequence entirely. Instead, you want to show the text without playing audio.

To do this and show the text for a duration based on the text length, set the sequence to:

Code: Select all

AudioWait(entrytag)
This will process the audio, but if Mute is true then it won't actually play it; it will just silently wait for an equivalent amount of time.

If, when the player turns off voiceover, you instead want to show the text immediately without waiting, set the sequence to:

Code: Select all

{{voiceover}}
and define a sequence shortcut named "voiceover". When the player has specified to hear voiceover, set this shortcut to AudioWait(entrytag):

Code: Select all

Sequencer.RegisterShortcut("voiceover", "AudioWait(entrytag)");
If the player has turned off voiceover, set the shortcut to:

Code: Select all

Sequencer.RegisterShortcut("voiceover", "Continue()");
This will immediately continue to the next step in the conversation without playing any audio.