Setting Barks to Random by Script Doesn't Work

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
tmeans825
Posts: 10
Joined: Sat Mar 27, 2021 5:32 pm

Setting Barks to Random by Script Doesn't Work

Post by tmeans825 »

Hello-

I have a character with a dialogue system trigger on them. Trigger = On Use.

The action includes Barks.

I have a script that eventually changes the bark conversation values in the following way:

Code: Select all

milo.GetComponent<DialogueSystemTrigger>().barkConversation = "Homestead/Act 1/Milo/Generic Barks";
milo.GetComponent<DialogueSystemTrigger>().barkOrder = BarkOrder.Random;
In the Editor, everything looks right - including showing the Bark Order being Random. However, the character will only ever bark the very first available bark in the conversation, it is not random.

There are no conditions added to any of the dialogue entries.

Any ideas? Thanks!
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Setting Barks to Random by Script Doesn't Work

Post by Tony Li »

Hi,

To keep track of bark order, the Dialogue System Trigger creates a BarkHistory object the first time it barks. It uses the barkOrder variable to create the BarkHistory object, but then it doesn't observe the barkOrder after that. If this Dialogue System Trigger has barked before, then changing the barkOrder variable will do nothing.

Here are two solutions:

1. Set up two different Dialogue System Triggers -- one with sequential barks, another with random barks. Disable one and enable the other.

2. Or, to use the same Dialogue System Trigger, make a subclass so you can access the protected BarkHistory property. Then use this subclass. Example:

Code: Select all

public class DialogueSystemTriggerWithChangeableBarkOrder : DialogueSystemTrigger
{
    public void SetBarkOrder(BarkOrder barkOrder)
    {
        BarkHistory.order = barkORder;
    }
}
Post Reply