Sequential Barks from separate NPCs

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Zooch
Posts: 4
Joined: Thu Jun 20, 2019 9:11 pm

Sequential Barks from separate NPCs

Post by Zooch »

Hi all,

I'm looking to set up an event where my player wakes up from a nightmare and says a bark line, something like "wow crazy". Then once the bark duration is over, I wanted another NPC across the room to bark "get over here." I have gotten both barks to work independent of each other, but I don't know how to get the second bark to automatically trigger once the first bark is finished.

I'm attemping to run some scripts to turn off player inputs and our camera follow functionality during the OnBarkStart of the first bark, then enable them again on the OnBarkEnd of the second bark.

In short - how do I chain two barks together from different assets in the scene?

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

Re: Sequential Barks from separate NPCs

Post by Tony Li »

Hi Zach,

There are two ways:

1. Using Barks: Add a Dialogue System Trigger to the NPC, set to OnUse, with a Bark action. In the player's Dialogue System Trigger, add an OnExecute() event. Configure the OnExecute() event to invoke the NPC's DialogueSystemTrigger.OnUse.

2. Using a Conversation: If you're chaining several barks together, I recommend using a conversation instead. Barks are primarily intended to be one-offs, whereas conversations are for sequences of nodes.
  • If you want characters to always talk using overhead text, add a Dialogue Actor component to the character and assign Dialogue UI Settings > Custom, Bubble Template Standard Dialogue UI.
  • If you want other conversations to use a regular screen space UI and you only want this one bark sequence to use barks, then put an Override Dialogue UI component and a Bark Dialogue UI component on the NPC. Assign the Bark Dialogue UI component to the Override Dialogue UI.
Zooch
Posts: 4
Joined: Thu Jun 20, 2019 9:11 pm

Re: Sequential Barks from separate NPCs

Post by Zooch »

Thanks for the quick response Tony.

Setting it up in terms of option 1 allows for both barks to play at the same time. Is the OnExecute() firing as soon as the trigger script is triggered? I'm looking for something that will allow the barks to happen sequentially (even if I have to set a manual delay for X seconds).

Based on what you're describing, I'm guessing that I'm doing this incorrectly and I should indeed be using conversations instead. Regardless, given that I'm 98% complete with my goal using barks, I'm hoping I can finish what I've started with the knowledge that conversations are the way to go in the future.

Thanks for your time,

Zach
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sequential Barks from separate NPCs

Post by Tony Li »

Doh, sorry, I have no idea what I was thinking. Please ignore what I wrote earlier. Use another Dialogue System Trigger set to OnBarkEnd. On NPC1:

Image

It has an OnExecute() that triggers NPC2's Dialogue System Trigger when the first bark ends:

Image
Zooch
Posts: 4
Joined: Thu Jun 20, 2019 9:11 pm

Re: Sequential Barks from separate NPCs

Post by Zooch »

Your suggestion makes total sense, and I've set it up in the same fashion as what you have in the screenshots (thank you for the great level of detail and clarity in instruction!). It's still playing at the same time though.

My player script, which fires the "wake up" text OnStart (or OnTriggerEnter, I've tried both):
PlayerScripts.png
PlayerScripts.png (47.24 KiB) Viewed 909 times
My NPC script, which fires the "get downstairs" text OnUse:
NPCScripts.png
NPCScripts.png (26.54 KiB) Viewed 909 times
The only discrepancy I can see is that you're using Text and I'm using Conversations, so I tried changing mine to Text for both barks just to eliminate the variables and it didn't change anything - they still played simultaneously.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sequential Barks from separate NPCs

Post by Tony Li »

Here's an example scene:

ChainedBarkExample_2019-06-21.unitypackage

I exported it from Unity 2018.3.10. It uses the Dialogue System's Demo scene assets.

There are 2 NPCs. They do this:
  • Enemy: On start, barks a random conversation line from "Enemy Barks" (e.g., "Die!") then triggers Sgt. Graves.
  • Sgt. Graves: Barks some text (no difference from conversation; the database just didn't have an appropriate conversation). Then triggers Enemy again.
  • Enemy: Barks another random conversation line.
Zooch
Posts: 4
Joined: Thu Jun 20, 2019 9:11 pm

Re: Sequential Barks from separate NPCs

Post by Zooch »

We were able to get your scene working inside our project, but we couldn't recreate it within the scene we were using. I'm going to chalk it up to being a cursed environment for now. We were able to solve it with a somewhat inelegant way - adding a Delay() to the end of the first conversation sequence.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sequential Barks from separate NPCs

Post by Tony Li »

Got it. Sometimes one just has to get it working and move on to more pressing matters. But if it ends up haunting you in your sleep or something, feel free to send a reproduction project to tony (at) pixelcrushers.com. I'll be happy to take a look.
Post Reply