How to Set Up NPCs

NPCs and other interactive objects are usually represented by in-game avatars, although this isn't absolutely required for the Dialogue System. This page contains instructions that you can follow to set up an NPC or an interactive object such as a computer terminal. The rest of this page refers to "NPC", but the same procedures apply to interactive objects.

Overview

In addition to the typical Unity components such as a renderer and possibly a collider and/or trigger, NPCs in the Dialogue System usually have these types of components:

Component Type Description
Usable Marks the NPC "usable," meaning the player can target it and send "OnUse" messages
Bark UI Displays barks. Only applicable if the NPC is configured to bark
SetEnabled Controllers Optionally disable components (such as AI movement) during conversations
Modifiers Modify how the player works in the Dialogue System, such as specifying the player's default camera angle
Persistent Data Saves info in saved games and between level changes. Only applicable if you use the Save System

NPC Setup Wizard

The NPC Setup Wizard will automatically add the appropriate Dialogue System components to your NPC to give it the behavior that you specify. This is usually the easiest way to set up your NPC.

To use the wizard, select Window > Dialogue System > Wizards > NPC Setup.

Each page of the wizard contains an explanation of the options available to you.

Configure each page as appropriate for your project. Here are some notes:

  • Assign the dialogue database that contains the NPC's content.
  • If the NPC has a conversation, set the trigger mode to specify when the conversation will fire.
  • If the NPC has a bark, make sure to add a bark UI.
  • If prompted, click Add Collider and/or Add Usable.

The rest of this page describes the component types in more detail and explains how to add them manually.


Usable

The Usable component marks an NPC "usable," which allows the player to target it with a Selector or Proximity Selector and send an "OnUse" message.

More information: Usable


Bark UI

A bark UI displays barks, which are one-off lines of dialogue that are not part of an interactive conversation. The bark UI can be written for any GUI system. The Dialogue System includes bark UIs for Unity GUI, NGUI, Daikon Forge GUI, 2D Toolkit UI, etc.

If you only want one NPC in a group to bark at a time, use Bark Groups.

More information: Bark UI


"OnUse" Triggers

If you've marked the NPC as "usable", add one or more triggers that respond to the "OnUse" message, such as Conversation Trigger or Bark Trigger.

You can add multiple triggers with different trigger conditions on each.

You can also add Bark On Idle if you want the NPC to bark on a timed interval, independent of being used by the player.

More information:


SetEnabled Controllers

When the NPC is in a conversation, you will often want to temporarily turn off components such as AI wander scripts. The Set Component Enabled On Dialogue Event component can be configured to disable these components when a conversation starts, and then re-enable them when the conversation ends.


Modifiers

Override Actor Name

By default, conversations use the name of the NPC GameObject as the NPC's name. This name is used in portrait labels and is the value assigned to Variable["Conversant"]. You can specify a different name by adding an Override Actor Name component.

Override Actor Name

If your dialogue UI uses the NPC Portrait Name field (or PC Portrait Name field for players), the text will be set according to these rules:

  1. If a GameObject has been assigned as the conversation's Conversant, the text will be the GameObject's name. (If the line is spoken by the player, it will use the GameObject assigned as the Actor.)
  2. However, if the GameObject has an Override Actor Name component, it will use the name in this component instead of the GameObject's name.
  3. If no GameObject is assigned to the Conversant, it will use the name of the actor assigned as the conversation's conversant in the dialogue database.
  4. If the line is spoken by a third character (neither the Actor nor the Conversant), it will search for a GameObject in the scene whose name matches the actor's name in the dialogue database. If it finds one, it will use that GameObject name or its Override Actor Name component. Otherwise it will use the name in the database.

Default Camera Angle

Every actor has a default camera angle that cutscene sequences can reference. Unless specified otherwise, the angle is "Closeup". You can change the NPC's angle by adding a Default Camera Angle component. For example, if the NPC is terrifying giant, you might want the default angle to be "Up" to convey that the PC must look up at him.


Persistent Data

Persistent data components are only applicable if you use the Save System. They're described in detail in the Save System section.


Components on Child GameObjects

You can put Components On Child GameObjects.


<< How to Set Up the Player (PC) | How to Start Conversations >>