This section explains how to make things happen in the Dialogue System.
The Dialogue System Trigger component has three main parts:
You can set the Trigger dropdown to these values:
Trigger | Description |
---|---|
On Use | The player’s Selector or Proximity Selector sent an OnUse message to the GameObject, or the Dialogue System Trigger’s OnUse() method was called manually in a UnityEvent or script. |
On Start | The component started (e.g., at scene start). |
On Enable | The component was enabled. |
On Disable | The component was disabled. |
On Destroy | The component was destroyed. |
On Trigger Enter | The component received an OnTriggerEnter message. To use this trigger, the component’s GameObject should have a trigger collider. You may want to set Conditions → Accepted Tags to restrict this trigger to GameObjects with specific tags such as Player. |
On Trigger Exit | The component received an OnTriggerExit message. |
On Collision Enter | The component received an OnCollisionEnter message. |
On Collision Exit | The component received an OnCollisionExit message. |
On Bark Start | The GameObject started playing a bark (one-off line of dialogue). |
On Bark End | The GameObject finished playing a bark. |
On Conversation Start | The GameObject just started as a primary participant in a conversation. |
On Conversation End | The GameObject just ended a conversation. |
On Sequence Start | The GameObject just started as a primary participant in a cutscene sequence. This event is not called for in-conversation sequences unless you’ve ticked the Dialogue Manager’s Subtitle Settings → Inform Sequence Start And End checkbox. |
On Sequence End | The GameObject just ended a sequence. |
Conditions allow you to specify states that must be true for the Dialogue System Trigger to fire, including:
Condition Type | Description |
---|---|
Lua Conditions | Lua expressions such as checking the value of a variable. |
Quest Conditions | Required quest states. |
Accepted Tags | For OnCollision and OnTrigger events, the other GameObject must have one of these tags. If Accepted Tags is empty, all GameObjects are allowed. |
Accepted GameObjects | For OnCollision and OnTrigger events, the other GameObject must be in this list. If Accepted GameObjects is empty, all GameObjects are allowed. |
To add actions to perfom, click the Add Action button. You can add these actions:
Action | Description |
---|---|
Set Quest State | Sets quest and/or quest entry states. (See Quests.) |
Run Lua Code | Runs Lua expressions. (See Logic & Lua.) |
Play Sequence | Plays a cutscene sequence. (See Cutscene Sequences) |
Show Alert | Shows an alert message through the dialogue UI. |
Send Messages | Uses Unity’s SendMessage() method to send messages to targets. |
Bark | Plays a bark (one-off line of dialogue) on a GameObject. |
Start Conversation | Starts a conversation. |
Set GameObjects Active/Inactive | Works on entire GameObjects. |
Set Components Enabled/Disabled | Works on specific components of a GameObject. |
Set Animator States | Sets animator states on GameObjects. Useful to idle characters when conversations start. |
OnExecute() UnityEvent | Allows you to specify other actions using a UnityEvent. |
Use Bark On Idle to play barks on a GameObject at a random frequency between Min Seconds and Max Seconds. See the Barks section for more information about barks.
Use Range Trigger to activate GameObjects and enable components OnTriggerEnter when specified Conditions are met. When OnTriggerExit occurs, the GameObjects are deactivated and components disabled. This component is useful to enable components such as Bark On Idle only when the player enters a trigger collider that represents proximity to the barker. You can also configure UnityEvents to run on enter and exit.
The Trigger Event, Collision Event, and Timed Event components are general-purpose components that run UnityEvents on trigger collisions, regular physics collisions, and elapsed durations, respectively.
The Dialogue System Events component runs UnityEvents when Dialogue System activity occurs. Each foldout has a section of events that the component can handle when its GameObject receives the corresponding message, such as OnConversationStart. Note that many events, such as OnConversationStart, are only called on the two primary participants and the Dialogue Manager. If you want to run an event regardless of who the participants are, put the Dialogue System Events component on the Dialogue Manager.
You can also handle events in your own scripts by adding special methods described Scripting.
The Dialogue System provides an optional interaction system that can interact with GameObjects (e.g., NPCs) that have Usable components. You can add one of two components to the player:
The Selector component detects Usables by raycasting from a specified position, such as the mouse position or center of screen. When the player presses the use button, it sends an OnUse Message to the Usable.
The Proximity Selector component detects Usables when entering trigger colliders. When the player presses the use button, it sends an OnUse Message to the Usable.
When the player targets a Usable and presses the Use Key or Use Button, the Selector will send an OnUse(Transform player)
message to the usable GameObject. The Dialogue System's triggers, such as Dialogue System Trigger, respond to this message. Your own scripts can also respond to this message by adding an OnUse method such as:
Interactive conversations usually have a back-and-forth flow, where the actor says a line, then the conversant says a line, and so on. Barks, on the other hand, are one-off lines of dialogue that don't involve a player response menu or any back-and-forth. They're typically spoken by an NPC for atmosphere (e.g., "Nice weather today") or to give the player an idea of the NPC's internal state (e.g., "Reloading. Cover me!"). The content of barks can come from text strings or conversations.
To create a bark conversation, add all bark entries as children of the START node. In other words, the conversation tree will only be one level deep. When an actor barks, the Dialogue System will evaluate all children of the START node to generate a list of currently-valid entries. It will then choose an entry from this list and bark it. By setting Conditions on the bark conversation's dialogue entries, barks can be aware of the current game state. For example, an NPC could bark different things based on its health level.
You can specify priority levels on your bark entries to prevent lower-priority entries from interrupting higher ones. To do this, add a custom Number field named "Priority" to your dialogue entry. Higher values have higher priority. If you don't want to have to add this custom field on each entry, you can add it to the template on the Dialogue Editor Templates Tab. If the dialogue entry doesn't have a custom field named "Priority", it uses a default of 0. When a bark is triggered, if the NPC is already barking, the Dialogue System will only interrupt it to play the new bark if the new bark's Priority is greater than or equal to the current bark's Priority.
Barks don't use the dialogue UI. Instead, barks are played through a bark UI on the barker, which usually appears as text over the NPC's head and/or as audio played through the NPC's audio source. The Dialogue UIs section covers bark UIs.
If you want only one barker in a group to show bark text at time, configure them as Bark Group Members by adding a Bark Group Member component to each. When one member of the group barks, the others will hide any active barks to reduce onscreen clutter.
The Dialogue System supports 2D physics as well as 3D physics. In Unity 2018+, the 2D physics package (Physics2D) can be enabled or disabled, so the Dialogue System's code for Unity 2018+ doesn't assume that Physics2D is available in your project. To tell the Dialogue System that Physics2D is available if you’re using Unity 2018+, select menu item Edit → Settings → Player, add the scripting symbol USE_PHYSICS2D
as shown below:
If you’re using Unity 2017 or older, you can skip this step.
<< Welcome to the Dialogue System for Unity! | Dialogue UIs >>