This page contains a discussion of how to integrate "conversation mode" with your project's regular "gameplay mode."
When setting up your project infrastructure, integrating PC-NPC dialogue with gameplay is one of the more complicated tasks, because you need to transition player control from gameplay mode (looking around, moving, etc.) to conversation mode. Generally, you need to temporarily disable gameplay controls and NPC AI, and get the NPC to act the way you want in conversation mode.
To do this, you can use triggers such as Set Enabled On Dialogue Event and/or sequencer commands such as SetEnabled().
The general approach is:
In addition, you may need to share data between the Dialogue System and your gameplay framework (for example, the player's inventory or health). One good approach is to use the Dialogue System's Lua environment and the OnConversationStart/OnConversationEnd messages:
Message | Task |
---|---|
OnConversationStart | Record your gameplay data into the Lua environment so your conversation can access and/or manipulate it |
OnConversationEnd | Apply any changes from the Lua environment into your gameplay data |
The FPSyncLuaPlayerOnConversation.cs script demonstrates how this is done in VisionPunk's UFPS. It uses the DialogueLua
class to store and retrieve UFPS data in the Lua environment.
The Feature Demo can give you an overview of how to integrate the Dialogue System with your own gameplay components.
In the Feature Demo example scene, the Player object has a Set Enabled On Dialogue Event component that disables these gameplay components on conversation start:
The same component also re-enables them on conversation end.
In addition, the first dialogue entry in Private Hart's conversation uses the LookAt() sequence command to make the player and Hart look at each other.
<< Save System | Scripting >>