Barks
Barks are short lines an agent says on its own, without anyone talking to it: a blacksmith complaining about the heat, a guard calling out the hour. A bark can be text above the agent's head, an audio clip, or both.
Barks are not conversations. A conversation is authored as an exchange, both sides take part, and it holds the agents still. A bark is a single line that plays and is gone, and the agent carries on with whatever it was doing.
How a bark is chosen
Every few seconds, each agent near the camera gets a chance to bark. For each agent, in order:
- Skip it if it's paused, in a conversation, already barking, barked too recently, or inside a node that blocks barks.
- Go down the General bank from the top and take the first collection whose requirements the agent meets.
- Skip it if that collection is on cooldown for this agent, or its probability roll fails.
- Pick a line from the collection by weight, leaving out any line the agent said too recently.
The search stops at the first matching collection. If that collection is on cooldown or fails its roll, the agent doesn't bark this time. It doesn't try the next collection down, which is why ordering matters.
The pieces
| Asset | What it holds |
|---|---|
| Bark | One line: text, an audio clip, or both, and how long before the same agent can say it again. |
| Bark Collection | A weighted list of lines, the requirements an agent must meet to use them, a probability and a cooldown. |
| Bark Selector | An ordered list of collections. The General selector is the bank every agent uses. |
You can create all three from Create > BardTreeLtd > Civil AI > Bark, but the Bark Editor creates and connects them for you.
Creating general barks
- Open
BardTreeLtd/Civil AI/Bark Editor. - The first time, select Create General Bark Selector. It is saved to
Resources/CIVIL-AI-SYSTEM/BarkSystem/General. - Press + to add a collection, then add lines to it under Lines.
- Expand a line's Details to set its text, audio clip and minimum repeat time.
- Add requirements to limit which agents use the collection. A collection with no requirements is used by every agent.
Collection settings
| Setting | Default | Description |
|---|---|---|
| Name | New Collection | For your own reference. |
| Probability | 0.5 | Chance that an agent reaching this collection barks. |
| Cooldown (seconds) | 30 | After an agent barks from this collection, how long before it can use it again. |
| Requirements | none | What an agent must meet to use the collection. See Requirement System. |
Line settings
| Setting | Default | Description |
|---|---|---|
| Weight | 1 | Chance of this line against the others in the collection. 0 turns it off. |
| Text | empty | Shown above the agent. |
| Audio Clip | none | Played from the agent. |
| Minimum Repeat (seconds) | 20 | The same agent won't say this line again within this time. |
A line needs text, an audio clip, or both. A line with neither is skipped.
A line can be used in more than one collection. Its repeat time is tracked for each agent, whichever collection the line came from.
Barks for a job
To give one job its own barks, start from the job itself. In the Behaviour Tree Editor, expand the Barks section on a job node and select Add Bark Collection. This:
- creates a collection named after the job
- adds a requirement that only agents doing that job meet
- adds the collection to the General bank
- opens the Bark Editor on it, ready for lines
The job's Barks section lists the collections that belong to it, each with an Edit button.
The requirement matches the job by its id rather than its name, so renaming the job doesn't break it.
Save the tree before adding barks to a job you've just created. A job that hasn't been saved yet can't be looked up by name, so its collection is just called "Job". It still works, and you can rename it in the Bark Editor.
Ordering
Because the first matching collection wins, put specific collections above general ones. A collection with no requirements matches every agent, so nothing below it is ever reached.
Add Bark Collection adds new collections to the bottom of the list. If you have a catch-all collection, drag each new job collection above it.
Drag collections in the Bark Editor to reorder them. The number on each one is its position, with #0 checked first.
Blocking barks
Sometimes an agent should stay quiet, such as while it sleeps or hides. Every node in the Behaviour Tree Editor has a Block Barks option in its Barks section. This covers job, duty, task, method, action and need nodes.
While an agent is in a blocked node, or anything beneath it, it won't start a bark. Blocking a job silences everything the agent does for that job. Blocking a single method silences only that method.
- Save the tree for a change to take effect. Blocks are stored in a
BarkNodeMappingasset saved beside the tree. - A line already being said is allowed to finish.
Barks and conversations
When CIVIL-DIALOGUE-SYSTEM is installed, barks always give way to conversations:
- An agent in a conversation doesn't bark.
- If a conversation starts while an agent is barking, the bark stops.
- When a conversation ends, everyone who took part stays quiet for a while, set by Post-Conversation Hush.
Text
Bark text appears above the agent's head and follows it as it walks. How long it stays up depends on the length of the line, between Minimum Hold and Maximum Hold. If the line also has an audio clip, the text stays up at least as long as the clip.
With CIVIL-DIALOGUE-SYSTEM installed, barks use its overhead text bubble instead, so barks and conversation lines look the same. See With CIVIL-DIALOGUE-SYSTEM.
Bark text needs TextMeshPro's essential resources. If they're missing, a warning is logged and text is turned off, but audio still plays.
Audio
- Clips play from the agent in 3D. If the agent has no Audio Source, one is added. If it already has one, that Audio Source keeps its own settings.
- Each agent speaks at a slightly different pitch, which stays the same every time. This stops a crowd sharing the same recordings from sounding identical. Set Pitch Variation to 0 to turn it off.
- No more than Max Concurrent Audio bark clips play at once. Barks over the limit still show their text.
Settings
Bark settings are on the Barks tab of BardTreeLtd/Civil AI/Module Settings.
Scheduling
| Setting | Default | Description |
|---|---|---|
| Enabled | on | Turns barking on or off. |
| Tick Rate | 3s | How often agents get a chance to bark. |
| Tick Jitter | 0.25 | Varies the tick rate by up to this fraction, so a crowd doesn't bark in unison. |
| Bark Up To Band | 2 | Only agents in bands below this one bark. 1 means only the nearest band. See Rendering Groups. |
| Probability Scale | 1 | Multiplies every collection's probability. 0 silences barks. |
| Agent Cooldown | 15s | Shortest time between two barks from the same agent. |
| Post-Conversation Hush | 5s | How long an agent stays quiet after a conversation ends. |
Audio
| Setting | Default | Description |
|---|---|---|
| Max Concurrent Audio | 4 | Most bark clips playing at once. |
| Audible Distance | 20 | Distance at which a bark can no longer be heard. |
| Mixer Group | none | The audio mixer group bark audio plays through. |
| Pitch Variation | 0.08 | How far above or below normal an agent's pitch can be. |
Audible Distance and Mixer Group only apply to Audio Sources added by barks. An Audio Source already on the agent keeps its own values.
Text
| Setting | Default | Description |
|---|---|---|
| Show Text | on | Shows bark text above agents. |
Without CIVIL-DIALOGUE-SYSTEM, the look of the text is set here:
| Setting | Default | Description |
|---|---|---|
| Head Offset | (0, 2, 0) | Where the text sits relative to the agent. |
| Max Width | 4 | Width the text wraps at, in world units. |
| Font Size | 36 | Size of the text. |
| Text Colour | white | Colour of the text. |
| Show Background | on | Draws a panel behind the text. |
| Background Colour | 50% black | Colour of the panel. |
| Background Padding | (0.15, 0.08) | Space around the text, in world units. |
| Fade Duration | 0.2s | Time to fade in and out. 0 shows and hides instantly. |
Pacing
| Setting | Default | Description |
|---|---|---|
| Characters Per Second | 18 | Reading speed used to work out how long text stays up. |
| Minimum Hold | 1s | Shortest time text stays up. |
| Maximum Hold | 4s | Longest time text stays up. |
With CIVIL-DIALOGUE-SYSTEM
When both products are installed:
- Barks use the dialogue system's overhead text bubble instead of their own.
- The bubble's look comes from the dialogue system's Overhead Text settings: font, size, width, colours, background, offset, fade, bubble prefab, and the typewriter.
- The Barks tab shows the same appearance settings in place of its own. Changing them there changes the dialogue module settings, so barks and conversations always match. Select Open Dialogue Module Settings for everything else.
- The dialogue system's overhead text Enabled and Headless Only options don't affect barks. Use Show Text on the Barks tab instead.
- When the dialogue typewriter is on, a bark stays up until its line has finished typing, even if that goes past Maximum Hold.