Page 1 of 1

Stop Bark

Posted: Wed Dec 30, 2020 8:21 pm
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).

Re: Stop Bark

Posted: Wed Dec 30, 2020 9:09 pm
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.

Re: Stop Bark

Posted: Wed Dec 30, 2020 10:04 pm
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!

Re: Stop Bark

Posted: Thu Dec 31, 2020 8:15 am
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.

Re: Stop Bark

Posted: Mon Jan 04, 2021 2:58 pm
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.

Re: Stop Bark

Posted: Mon Jan 04, 2021 3:12 pm
by Tony Li
Hi,

If it ends up being an issue, please feel free to send me a reproduction project.

Re: Stop Bark

Posted: Mon Jan 04, 2021 3:20 pm
by VoodooDetective
Will do, thanks again!