This page describes how to set up the Dialogue System with Opsive's deprecated Third Person Controller version 1. (Third Person Controller is required.)
For instructions on current Opsive Character Controller integration, see Opsive Character Controllers Support.
Third Person Controller copyright © Opsive.
This integration gives you the ability to control the TPC player character and camera during conversations, and also provides a way to change and save characters' stats (such as health) and inventory.
For instructions on current Opsive Character Controller integration, see Opsive Character Controllers Support.
EnableTpcControl()
and DisableTpcControl()
in a script or sending the messages "EnableTpcControl" and "DisableTpcControl".The Interact ability is required to interact with things, such as NPCs who start conversations when interacted with.
TPC's Character Builder doesn't automatically add the Interact ability. To add it:
This integration package provides two components that you can add to your TPC-controller characters (players and/or NPCs) to expose Unity Events that you can configure in the inspector:
You can use this sequencer command in your dialogue entry Sequence fields.
TPCCameraState( state, [apply] )
Sets the TPC camera state.
TPCAbility( abilityName, [subject], [ignorePriority] )
Tries to start an ability on a TPC subject.
You can use the Lua functions below in your dialogue entry Scripts and Conditions (or anywhere you use Lua). Note the exact number and type of parameters required for each function.
If you're creating a multiplayer game, you can also use Lua Networking Functions to synchronize variables and quest states across all clients.
tpcGetHealth( characterName:string )
Returns: (number) The current health of the character.
Description: If characterName is a blank string, gets the player's health.
Example: tpcGetHealth("")
tpcGetShield( characterName:string )
Returns: (number) The current shield strength of the character.
Description: If characterName is a blank string, gets the player's shield.
Example: tpcGetShield("")
tpcSetInvincible( characterName:string, value:Boolean )
Description: Sets a character invincible or not. If characterName is a blank string, affects the player.
Example: tpcSetInvincible("Adam", true)
tpcHeal( characterName:string, amount:number )
Description: Heals a character. If characterName is a blank string, affects the player.
Example: tpcHeal("", 50)
tpcDamage( characterName:string, amount:number )
Description: Damages a character. If characterName is a blank string, affects the player.
Example: tpcDamage("Some NPC", 50)
tpcSetMaxHealth( characterName:string, amount:number )
Description: Sets a character's max health. If characterName is a blank string, affects the player.
Example: tpcSetMaxHealth("", 150)
tpcSetMaxShield( characterName:string, amount:number )
Description: Sets a character's max shield strength. If characterName is a blank string, affects the player.
Example: tpcSetMaxShield("", 200)
tpcSetShieldRegenerativeAmount( characterName:string, amount:number )
Description: Sets a character's shield regenerative amount. If characterName is a blank string, affects the player.
Example: tpcSetShieldRegenerativeAmount("", 0.2)
tpcHasCurrentItem( characterName:string, itemName:string, primaryItem:Boolean )
Returns: (Boolean) True
if a character has an item; otherwise false
.
Description: Checks if a character has an item. The item must be in at least one bridge component's Item Types list. If characterName is a blank string, affects the player. If primaryItem is true, checks the primary item; otherwise checks the secondary item.
Example: tpcHasCurrentItem("", "Pistol", true)
tpcGetItemCount( characterName:string, itemName:string, loadedCount:Boolean )
Returns: (Number) The count of an item (or its ammo, for weapons).
Description: Gets the amount of an item owned by a character. The item must be in at least one bridge component's Item Types list. If characterName is a blank string, affects the player. If loadedCount is true, checks the loaded count; otherwise checks the unloaded count.
Example: tpcGetItemCount("", "Pistol", true)
tpcPickupItem( characterName:string, itemName:string, amount:number, equip:Boolean, immediateActivation:Boolean )
Description: Gives the character an item. The item must be in at least one bridge component's Item Types list. If characterName is a blank string, affects the player. If equip is true, also equips the item. If immediateActivation is true, activates immediately; if false, plays an equip animation.
Example: tpcPickupItem("", "Shotgun", 1, true, true)
tpcRemoveItem( characterName:string, itemName:string, immediateRemoval:Boolean )
Description: Removes an item from a character. The item must be in at least one bridge component's Item Types list. If characterName is a blank string, affects the player. If equip is true, also equips the item. If immediateRemoval is true, removes immediately; if false, plays an unequip animation.
Example: tpcRemoveItem("", "Shotgun", true)
tpcRemoveAllItems( characterName:string )
Description: Removes all items from a character. If characterName is a blank string, affects the player.
Example: tpcRemoveAllItems("Doug")
To save TPC character data, add a Dialogue System Third Person Controller Bridge and tick the Record Stats, Record Position and/or Record Inventory checkboxes. The bridge will include the character's position and/or inventory in saved games under the actor name in Override Actor Name field or the GameObject name if the field is blank. Record Current Level also records the level that the character is in. This is only useful for the player character (PC) and companions that might follow the PC across different levels.
If you're creating a multiplayer game, add a Lua Network Commands component to your player prefab to make the Lua Networking Functions available. You can then use these functions to synchronize variables and quest states across all clients.
The Dialogue System Third Person Controller Bridge and Dialogue System Interactable components are multiplayer-ready.