Cancel and Randomize barks via script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
domopuff
Posts: 25
Joined: Fri May 13, 2022 2:26 am

Cancel and Randomize barks via script

Post by domopuff »

Hey Tony,

Is there a script method to cancel all active barks? I tried using BarkGroupManager.instance.CancelAllBarks() but doesn't seem to work.

Also was wondering if there's a way to trigger and randomize barks via script as well?

Thank you!
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Cancel and Randomize barks via script

Post by Tony Li »

Hi,

To cancel all barks, add BarkGroupMember components to your barking characters. Then BarkGroupManager.instance.CancelAllBarks() will tell all BarkGroupMembers to cancel any active barks.

To trigger randomized barks in C#, use DialogueManager.Bark() to DialogueManager.BarkString(). If your conversation only has two dialogue entries to randomize from, Dialogue System version 2.2.50 will have a fix that randomly chooses between the two. (Currently it always uses the first entry if there are only two.)
domopuff
Posts: 25
Joined: Fri May 13, 2022 2:26 am

Re: Cancel and Randomize barks via script

Post by domopuff »

Thanks for the help Tony. Would there also be a way to sequentially trigger barks as well? Or i just need to ensure the previous bark doesn't repeat itself again.
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Cancel and Randomize barks via script

Post by Tony Li »

Hi,

Create a BarkHistory object and pass it along. Example:

Code: Select all

private BarkHistory barkHistory = new BarkHistory(BarkOrder.Sequential);

void BarkNextSequentialLineInOrder()
{
    DialogueManager.Bark("My Bark Conversation", this.transform, barkHistory);
}
domopuff
Posts: 25
Joined: Fri May 13, 2022 2:26 am

Re: Cancel and Randomize barks via script

Post by domopuff »

Thanks it worked!
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Cancel and Randomize barks via script

Post by Tony Li »

Glad to help!
Post Reply