custom AudioWait()

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

custom AudioWait()

Post by joeylu »

Hi Tony,
My project uses an audio middleware and has a lot of extended logics for playing audio, by checking the dialogue sequence command, I have found the AudioWait() requires direct access to the audio clip file.
So my first question is that if I need the AudioWait() to access a custom scriptable object file (our middleware), is that possible?

Say it is not possible and I need to write my own LUA script to handle the audio play, here are my questions:

1. In most case, my game allows player to click continue button to advance to the next dialogue node, if player does that, current audio voice for current entry should be immediately stopped, I guess I need call my middleware to stop the audio at OnConversationLineEnd() and also OnConversationCancelled(), am I missing any?

2. If the player does not click continue button to advance, the audio file should be fully played before dialogue automatically advance to next node, similar as AudioWait() does. But by default the dialogue duration is based on Character per second option with the total characters in a single node, can you give me a brief idea how to achieve this?

I actually have more questions but before we getting there, let's focus on the most important questions here first :)
User avatar
Tony Li
Posts: 21049
Joined: Thu Jul 18, 2013 1:27 pm

Re: custom AudioWait()

Post by Tony Li »

Hi,

Write a custom sequencer command for your middleware audio plugin. (If it's FMOD, just use FMODWait().)

Custom sequencer commands are fairly easy to write. There's a starter template in Plugins / Pixel Crushers / Dialogue System / Templates / Scripts. To learn how to write custom sequencer commands, please see the Cutscene Sequence Tutorials. The final video in the series covers custom sequencer commands.
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

Re: custom AudioWait()

Post by joeylu »

Tks for the quick reply
Writing custom sequence or custom LUA is not a problem, that's exactly what I'm working on
However, I might missed something from the template, seems I still cannot find an answer for my #2 question

2. If the player does not click continue button to advance, the audio file should be fully played before dialogue automatically advance to next node, similar as AudioWait() does. But by default the dialogue duration is based on Character per second option with the total characters in a single node, can you give me a brief idea how to achieve this?

can you guide me where to look for in your tutorials? or some brief logics that I can start with? tks

or to make it simple, how do you stop the dialogue entry (not letting it to advance to next entry both from script and sequence), as well as manually advance from script and sequence?
User avatar
Tony Li
Posts: 21049
Joined: Thu Jul 18, 2013 1:27 pm

Re: custom AudioWait()

Post by Tony Li »

Hi,

The subtitle duration is based on the Sequence, not necessarily on total characters.

If a dialogue entry's Sequence field is blank, it will use the Dialogue Manager GameObject's Display Settings > Camera & Cutscene Settings > Default Sequence.

The Default Sequence is initially set to:

Code: Select all

Delay({{end}})
which delays for a duration specified by the special keyword {{end}}. This keyword is determined by the total characters and the Dialogue Manager's Subtitle Settings > Subtitle Chars Per Second and Min Subtitle Seconds.

However, the Sequence (or Default Sequence) can be different. For example, if the Sequence is:

Code: Select all

Delay(3)
then the subtitle will delay for 3 seconds.

If the Sequence is:

Code: Select all

AudioWait(entrytag)
it will delay for the duration of the audio clip named by the entrytag keyword.

A Sequence is done when all of its sequencer commands have called their Stop() methods.

In your custom sequencer command, don't call Stop() until the audio is done playing.

Note: If the player clicks ahead using the continue button, your custom sequencer command's OnDestroy() method should stop the audio.
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

Re: custom AudioWait()

Post by joeylu »

got it, will give it a try, thank you Tony
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

Re: custom AudioWait()

Post by joeylu »

Hi Tony,
SequencerCommand works like a charm :)
But I still need your advice.

Say if I need to get the current actor, and current subtitle text in SequencerCommand, I can pass the actor name as the parameter, or pass the dialogue entry id as the parameter, then lookup the entry in DialogueManager.

So my question is that is there a built in way in SequencerCommand the access the dialogue entry that is currently being played? Manually passing a string parameter for dialogue entry id is a bit unsafe if entries are constantly changing.
User avatar
Tony Li
Posts: 21049
Joined: Thu Jul 18, 2013 1:27 pm

Re: custom AudioWait()

Post by Tony Li »

Hi,

In your sequencer command, the current subtitle is in DialogueManager.currentConversationState.subtitle. The current speaker is in the 'speaker' property.
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

Re: custom AudioWait()

Post by joeylu »

Thank you Tony, that solves my problem :)
User avatar
Tony Li
Posts: 21049
Joined: Thu Jul 18, 2013 1:27 pm

Re: custom AudioWait()

Post by Tony Li »

Glad to help!
achootwo
Posts: 1
Joined: Wed Sep 20, 2023 9:43 am

Re: custom AudioWait()

Post by achootwo »

For your first question, if you want AudioWait() to access a custom scriptable object file, it's generally possible with proper integration. Ensure your middleware supports this kind of extension.

Regarding your second set of questions:

To stop the audio when the player clicks continue, calling your middleware to stop the audio at OnConversationLineEnd() and OnConversationCancelled() is a good approach.

For automatic advancement after full audio playback, consider using coroutine or timers. Calculate the playback time based on character count and characters per second, then trigger the dialogue advancement.
Post Reply