Stop all barks onConversationStart

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Stop all barks onConversationStart

Post by ar4wy »

Hi Tony,

Is there a way to stop all barks when conversations become active? Right now, with "allow barks during conversation" set to false, if a bark is active, it fades while conversation is active (but does not call a new bark during conversation).

Is there a way to cut all barks off when the conversation starts?
User avatar
Tony Li
Posts: 22140
Joined: Thu Jul 18, 2013 1:27 pm

Re: Stop all barks onConversationStart

Post by Tony Li »

Hi,

There isn't a built-in checkbox or anything like that, but you could add a small script to the Dialogue Manager, something like this:

Code: Select all

public class HideBarksOnConversation : MonoBehaviour
{
    void OnConversationStart(Transform actor)
    {
        foreach (var barkUI in FindObjectsOfType<StandardBarkUI>())
        {
            if (barkUI.isPlaying) barkUI.Hide();
        }
    }
}
Alternatively, you could use Bark Groups. Add a Bark Group Member component to all NPCs that can bark, and assign the same ID. When one member barks, the others will immediately hide their bark UIs if they're currently barking.

Add another Bark Group Member to the Dialogue Manager. When the conversation starts, manually call BarkGroupManager.instance.MutexBark(ID, DialogueManager.instance.GetComponent<BarkGroupMember>()).
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Re: Stop all barks onConversationStart

Post by ar4wy »

Hi Tony,

Thanks for this. After making a small script as described above, barks hide properly when conversation starts. However, when the conversation ends the barks seem to have a very short duration time now, even though in the inspector, barks still show "4" for Duration.
User avatar
Tony Li
Posts: 22140
Joined: Thu Jul 18, 2013 1:27 pm

Re: Stop all barks onConversationStart

Post by Tony Li »

Hi,

Do your barks use Sequences? If so, please try calling barkUI.OnBarkEnd(null) instead of barkUI.Hide().
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Re: Stop all barks onConversationStart

Post by ar4wy »

Hi Tony,

My Barks don't have any sequences. I tried what you suggested and the result is that it doesn't deactivate the bark.

I do have a default sequence in the Dialogue System Controller: Delay(0)@Message(Typed)

HOWEVER--I checked "Wait Until Sequence Ends" in the StandardBarkUI, and with the original Hide() call, it now works great. The barks get hidden when conversation starts and continue normally after conversation has ended.

My problem is resolved--but not sure why! haha.
User avatar
Tony Li
Posts: 22140
Joined: Thu Jul 18, 2013 1:27 pm

Re: Stop all barks onConversationStart

Post by Tony Li »

Hmm, barks don't use the Default Sequence. Anyway, glad it's working. I've made a note to investigate the issue when that checkbox wasn't ticked. I suspect the Hide() method just needs to reset something when it's not ticked.
ar4wy
Posts: 26
Joined: Fri Nov 15, 2019 10:16 pm

Re: Stop all barks onConversationStart

Post by ar4wy »

Thanks!!
Post Reply