Interacting with NPC
- Last UpdatedDec 06, 2023
- 1 minute read
A player can interact with Non Playing Characters.
Create interactions for NPC
-
Create an ItemBasic node and call it item_NPCNAME.
-
When picking the NPC in selection mode the system assumes to pick the item_NPCNAME.Thanks to the loose mesh naming search, the NPC avatar cmesh is recognized as the item one.
-
With User actions, you can define different interactions with the NPC, such Talk or Give.
-
The Active and Actionable parameters of user action permit enable you to present different actions according to different situations.
-
The developer must implement a corresponding behavior to occur when a NPC-related action is triggered.
For example, Talk might open a multi-option menu to allow the player to decide what to tell the NPC.
Code example
A code example for scripting NPC interaction.
<ItemBasic name="item_NPC_colleague" displayName="Collegue" displayValue="" group="Collegues" userActions="talk">
<patch name="item_NPC_colleague" action.talk.active="true" action.talk.actionable="true" action.talk.hotkey="none" action.talk.text="Talk"/>
</ItemBasic>
<share field="item_NPC_colleague.value" direction="inout" stateZero="true"/>