Stop Bark

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Stop Bark

Post by VoodooDetective »

I was just trying to figure out how to immediately short-circuit a bark.

This is my Bark Sequence:

Code: Select all

AudioWait(entrytag)@Message(BarkBubbleOpened);
BarkBubbleOpened is called when the bark bubble finishes its appear animation.
I also have WaitUntilSequenceEnds checked (assuming that would cause the bark
to close when the sequence was finished). I have duration set to 0.0001 so that the bark
depends solely on the sequence's end to decide when to close.
(0 won't work because the code seems to force a non-zero value)

I thought this would work:

Code: Select all

      DialogueManager.StopSequence(BarkController.LastSequencer);
However, even though the bubble closes as expected, the audio seems to continue playing.
Is there any way to immediately and completely stop the bark?



Side Note:
isPlaying in StandardBarkUI seems like it should be true when the bark is active and still playing a sequence, but it's not since it depends on the bark duration (which may be irrelevant if you're using sequences to determine the end).
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Stop Bark

Post by Tony Li »

Hi,

Barks are set-and-forget, so they don't provide many hooks to control them. One option is to make a subclass of StandardBarkUI, such as:

Code: Select all

public class MyBarkUI : StandardBarkUI
{
    private Sequencer mySequencer;
    
    public override void Bark(Subtitle subtitle)
    {
        base.Bark(subtitle);
        mySequencer = BarkController.LastSequencer;
    }
    
    public override void Hide()
    {
        base.Hide();
        if (mySequencer != null) mySequencer.Stop();
        var audioSource = GetComponent<AudioSource>();
        if (audioSource != null) audioSource.Stop();
    }
}
Alternatively, it might work to add a Dialogue System Events component (or a script with an OnBarkEnd method) to the barker that stops the audio source.
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Re: Stop Bark

Post by VoodooDetective »

Ahhh gotcha, OK thanks! I think I'll do this:

Code: Select all

        public override void OnBarkEnd(Transform actor)
        {
            base.OnBarkEnd(actor);
            speakerAudioSource.Stop(); // Kill Any Audio
        }
Because LastSequencer is set in a coroutine, it won't necessarily hold the correct Sequencer in Bark(), but in my case, since I never have multiple barks going at the same time, it's not an issue. I can just do:

Code: Select all

  DialogueManager.StopSequence(BarkController.LastSequencer);
Thanks for the help!
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Stop Bark

Post by Tony Li »

If you record LastSequencer in the Bark() method like in the example code of my previous post, it will point to the correct sequencer for the bark.
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Re: Stop Bark

Post by VoodooDetective »

Hey sorry I just saw this! That example code is exactly what I pasted in. Maybe I'm wrong as to why it wasn't working, but for me the value was incorrect (null). Maybe I had some other problem.
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Stop Bark

Post by Tony Li »

Hi,

If it ends up being an issue, please feel free to send me a reproduction project.
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Re: Stop Bark

Post by VoodooDetective »

Will do, thanks again!
Post Reply