How can I hide the current bark?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
ds2497
Posts: 49
Joined: Wed Jun 14, 2023 2:13 am

How can I hide the current bark?

Post by ds2497 »

Hi there!

I'm adding details to the bark on idle, and I would like to know:

A. How can I hide the current bark? For instance, I want the farmer Npc to conceal the ongoing bark line the moment he gets attacked.

B. How to switch a bark line? For example, the soldier Npc might be saying something cheerful when he's happy, but when he witnesses someone getting killed, he will stop the "Happy Bark" and switch to the "Anxious Bark." Here is my current code, but it's not working.

Image

Image

C. How do you set the duration of a bark? For instance, I want the bark UI to appear for only 3 seconds.

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

Re: How can I hide the current bark?

Post by Tony Li »

Hi,
ds2497 wrote: Sat Jul 22, 2023 1:25 amA. How can I hide the current bark? For instance, I want the farmer Npc to conceal the ongoing bark line the moment he gets attacked.
Call the bark UI's Hide() method. Example:

Code: Select all

public void OnAttacked()
{
    GetComponentInChildren<IBarkUI>().Hide();
}
ds2497 wrote: Sat Jul 22, 2023 1:25 amB. How to switch a bark line? For example, the soldier Npc might be saying something cheerful when he's happy, but when he witnesses someone getting killed, he will stop the "Happy Bark" and switch to the "Anxious Bark." Here is my current code, but it's not working.
That code should work, but another option is to set the Conditions fields of your bark conversation so choose the right barks:

barks.png
barks.png (25.61 KiB) Viewed 534 times

You could set a custom field in the actor and then check that field in the conversation. For example, say you've added a custom Boolean field named "IsInBattle". Set the Conditions of the <Idle> group node to:

Code: Select all

Actor["Your_Character"].IsInBattle == false
and do the same for the <In Combat> group node except check if it's true. Then some example C# code:

Code: Select all

public void OnAttacked()
{
    GetComponentInChildren<IBarkUI>().Hide();
    DialogueLua.SetActorField("Your Character", "IsInBattle", true);
}
ds2497 wrote: Sat Jul 22, 2023 1:25 amC. How do you set the duration of a bark? For instance, I want the bark UI to appear for only 3 seconds.
Inspect the bark UI and set its Duration to 3.

If you want to vary the duration for each bark, set Bark Duration to a low, minimum value and tick Wait Until Sequence Ends. Then set the Sequence field for each bark, such as this to delay for 2.5 seconds: Delay(2.5)
User avatar
ds2497
Posts: 49
Joined: Wed Jun 14, 2023 2:13 am

Re: How can I hide the current bark?

Post by ds2497 »

Thank you for your assistance!

I had the "Wait for Continue" option checked, which caused some features to not work as expected. It took me a while to resolve the issue, but everything is functioning correctly now. Thanks again!
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: How can I hide the current bark?

Post by Tony Li »

Glad you got it working!
Post Reply