Skip to main content

NPCs

Narrative Pro has a new NPC Subsystem which handles the spawning, creation, finding and all properties for NPCs.

All NPC details are stored as data assets, then spawned and managed by the Subsystem.

npc-data-assets.webp

Creating a new NPC

To create a new NPC, Narrative Pro comes packaged with a data asset type called ``.

Open Your Content Drawer -> Go to the folder where you want to store NPC Data Assets -> Right Click -> Miscellaneous -> Data Asset

npc-new-data-asset.webp

Select NPCDefinition and name it after your NPC. It will automatically populate some of the information based on the file name.

npc-new-data-asset-autofill.webp

Spawning an NPC

Using the NPC Manager you can spawn NPCs by getting the Narrative NPC Subsystem -> Spawn NPC

npc-spawning.webp

Another method of spawning NPC's into the world is to use Settlements

Data Asset Properties

NameTypeDescription
NPCIDFNameFName ID for this NPC
NPCNameFTextThe name of this NPC. Will be used for the interaction and navigation markers.
FactionObjectPtr<class UFactionDefinition>The NPC's faction, if one applies.
bAllowMultipleInstancesboolIs this NPC unique, or can we spawn multiple of them? Main characters, for example, generally only want a max of one spawned at a time, whilst a generic bandit might have as many instances as we want.
bInvulnerableboolIf true, we'll apply the Narrative.State.Invulnerable tag to this NPC by default - it can be removed if needed.
UniqueNPCGUIDFGuidIf this NPC is unique, we'll use this as the NPC's save system GUID. Since there is only one unique GUID defined here, this will nicely guarantee unique NPCs only ever have 1 save record created per NPC.
NPCClassPathTSoftClassPtr<ANarrativeNPCCharacter>The default class to create when spawning this NPC.
DialogueTSoftClassPtr<UDialogue>The dialogue that should play when we interact with this NPC.
TaggedDialoguesTArray<FTaggedDialogue>The NPC's tagged dialogues; these are essentially dialogue, usually free movement that can be kicked off via a tag "TaggedDialogue.Taunt, TaggedDialogue.Greet, etc."
bIsVendorboolWhether this NPC's inventory should be a vendor inventory.
TradingCurrencyint32Default currency this character should have in their inventory.
TradingItemLoadoutTArray<FLootTableRoll>The items we should grant the character by default.
ShopFriendlyNameFTextThe name of the vendor's shop, if this NPC is a vendor.
DefaultApperanceUCharacterAppearanceThe characters default appearance