Skip to content

Give an NPC a conversation

Designer · 15 min · No code

Result: a townsperson standing in your map. Walk up, a name plate and a Talk prompt appear, and pressing it plays a short exchange between them and the party leader.

Before you start

How an NPC is put together

There is one NPC Blueprint, Characters/NPC/B_XenoCore_Npc. A town is many placed copies of it, each with its own settings in the Details panel. You do not need a Blueprint per NPC for a plain conversation.

When the player presses the prompt, the NPC's On Interact graph runs. The default graph handles, in order: handing in a quest, offering a quest, a quest in progress, and plain talk. Plain talk plays the NPC's Dialogue list and closes the box. At the end of plain talk it also recruits the NPC's Member To Recruit and opens its Shop Table, if either is set; both do nothing on an NPC without them. To go beyond a list, see Branch a conversation.

Steps

1. Place the NPC

  1. Open your map. Drag Characters/NPC/B_XenoCore_Npc onto the floor.
  2. Select it. Everything below is set on this placed actor, in its Details panel.

A freshly placed NPC is blank: Display Name reads Townsperson, Interact Verb reads Talk, and there are no lines, no quest and no quest marker. For a finished example to copy, Characters/NPC/B_XenoCore_Npc_Sample is a child of the same Blueprint that carries the sample conversation and the sample quest.

2. Say who they are

Under XenoCore › NPC:

Setting Value What it does
Display Name Elder Maren The name plate, and the name on their lines
Quest (empty) No quest for this recipe
Has Quest Unticked (the default) Shows the quest marker when there is no Quest set. Leave it off.
Portrait optional Their face on screens that show one

Under XenoCore › NPC › Interaction:

Setting Value What it does
Interact Verb Talk The prompt text
Interact Range 200 How close the player must be for the name, marker and prompt. One number for all three.

Under XenoCore › NPC › Animation, set Idle Animation to a looping idle. To change how they look, select the inherited mesh component and change its mesh or materials on this placement.

3. Write the lines

Under XenoCore › NPC › Dialogue, open Dialogue and add one entry per line:

# Speaker Line Source
0 (empty) The old bridge washed out in the spring. Npc
1 (empty) If you're heading east, you'll have to go round by the cliffs. Npc
2 (empty) Thanks. We'll manage. Player
3 (empty) Safe travels, then. Npc
  • Source decides whose head the box floats over: Npc is this NPC, Player is the party leader.
  • Speaker is the name on the plate. Leave it empty to use the name of whoever the box is over: this NPC's Display Name, or the leader's own name. Type a name only when someone else is talking, for example a party member chipping in while the box stays over the NPC.
  • Keep each Line to about 165 characters. Longer lines still show in full, and a warning is logged.

4. Frame the conversation (optional)

Under XenoCore › NPC › Dialogue:

Setting Default What it does
Use Dialogue Camera Ticked The camera moves in over the leader's shoulder to frame both speakers, and back out when the box closes. Untick it for an NPC visited often, such as a vendor.
Dialogue Camera Rig (empty) A framing for this NPC alone, for example a giant. Empty uses Project Settings › XenoCore Content › Dialogue Camera Rig.
Face Player When Talked To Ticked The NPC turns to face the leader. Untick it for someone seated or behind a counter. The leader turns to face them either way.
Turn Back After Talking Ticked The NPC turns back to the way it was placed once the conversation ends.

5. Save the level

Press Ctrl+S, or File › Save Current Level.

Test it

  1. Press Play and walk towards the NPC. Within 2 m, their name and a Talk prompt appear.
  2. Press the prompt (pad A). The first line appears over their head.
  3. Press A to advance. Line 2 appears over the leader's head, with the leader's name.
  4. After the last line the box closes and you can move again.

While a line is on screen the party cannot move, and the camera does not turn. With Use Dialogue Camera on, the camera moves in when the conversation starts and returns to exactly where it was when it ends.

If it doesn't work

The NPC offers a quest you did not give them

You placed B_XenoCore_Npc_Sample, or duplicated it, rather than B_XenoCore_Npc. The sample carries the sample quest in Quest. Clear it on the placed actor, or place the blank Blueprint instead.

Fails silently: the prompt never appears

You are outside Interact Range, or another interactable (a chest) is nearer and takes the prompt. NPCs do not need any special collision; the prompt finds them by distance.

The name plate is blank

Display Name is empty, and so is the line's Speaker. For a player line, the leader's name comes from their party member definition.

An extra verb does not show

Only one extra verb can be pressed (pad X), so only the first Extra Interact Verbs entry is used, and none at all when the NPC has Trade Offers, because Trade takes that button. The rest are dropped with a warning in the Output Log.

Going further