Opsive Third Person Controller v1 Support

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.

Third Person Controller Setup

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.

Package Setup

For instructions on current Opsive Character Controller integration, see Opsive Character Controllers Support.

  1. To use the Dialogue System with Third Person Controller (TPC), contact Pixel Crushers for the integration package. It's no longer included with the Dialogue System package itself.
  2. Add a Dialogue Manager GameObject by adding the prefab in Prefabs.

Player Character Setup

  1. Select your player character.
  2. Make sure your player character has the Interact ability. If you're not sure, see Player Character Setup - Interact Ability.
  3. Add a Dialogue System Third Person Controller Bridge component (Component → Pixel Crushers → Dialogue System → Third Party Support → Third Person Controller → Dialogue System Third Person Controller Bridge).
    • By default, Deactivate During Conversations is ticked. When ticked, the bridge will disable TPC controls during conversations. You can manually enable and disable controls by calling EnableTpcControl() and DisableTpcControl() in a script or sending the messages "EnableTpcControl" and "DisableTpcControl".
    • By default, Record Stats, Record Position and Record Inventory are ticked. When ticked, the bridge will include the character's stats, 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.
    • Assign the TPC Inventory component's Unequipped Item Type (e.g., Fist) to the bridge's Unequipped Item Type field.
    • Add all item types that you plan to reference in the Dialogue System to the component's Item Types list. Click the Find Item Types button to automatically find all item types in the project, or manually add the ones you need.
  4. If you're not planning to tick the Interactable's Show Cursor During Conversation checkbox, you'll need to add a Show Cursor On Conversation component to the player.

Player Character Setup - Interact Ability

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:

  1. Select your player.
  2. Inspect the Rigidbody Character Controller component. The bottom of this component has a list of the player's Abilities. If it has an Interact ability, you can stop here.
  3. Otherwise, to add the Interact ability click "+" and select Interact.
  4. Configure the Interact ability to match the Doug character in the Dialogue System's TPC example scene:
    • Input Name: Action
    • Start Type: Button Down
    • Stop Type: Manual
    • Indicator: Interact (click the selection circle, then select the Interact icon)
    • Upper Body State Name*: (blank)
    • Left Arm State Name*: Interact
    • Can Have Item Equipped: ticked
    • * The animator State Names will depend on your player's animator controller. The settings given above are for the Shooter animator controller that ships with TPC. This is the animator controller that the Doug character uses in the example scene.

NPC Setup

  1. Select your NPC.
  2. If the NPC is TPC-controlled, add a Dialogue System Third Person Controller Bridge component and configure it as described in the Player Character Setup section above.
  3. Add a standard TPC Interactable component.
  4. Add a Dialogue System Interactable Target component (Component → Pixel Crushers → Dialogue System → Third Party Support → Third Person Controller → Dialogue System Interactable Target). Assign this component to the Interactable component's Target field. The Dialogue System Interactable Target component handles TPC interaction, redirecting a message such as "OnUse" to the Dialogue System.
  5. Add standard Dialogue System triggers such as Dialogue System Trigger. Set the Trigger to OnUse.

Controller Events

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:

  • Damaged Event: Provides an OnDamaged() event that reports when the character is damaged.
  • Ability Start Event: Provides an OnStartedAbility() event that reports when the character starts an ability. If Ability Name is blank, all abilities are reported. Otherwise only the named ability is reported. For example, if you want to advance a quest state when the player mounts his horse, you can configure this component similarly to this:

Sequencer Commands

You can use this sequencer command in your dialogue entry Sequence fields.

TPCCameraState( state, [apply] )

Sets the TPC camera state.

  • state: The name of the camera state (e.g., "Default", "Zoom").
  • apply: If true, applies the state. If false, reverts the state. Default: true.

TPCAbility( abilityName, [subject], [ignorePriority] )

Tries to start an ability on a TPC subject.

  • abilityName: The name of the ability's script. For example, the "Damage Visualization" ability's script name is "DamageVisualization".
  • subject: The TPC character to start the ability on. Default: speaker.
  • ignorePriority (true/false): If true, ignore ability priority. Default: true.

Lua Functions

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")

Saving and Loading

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.

Multiplayer

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.


<< Third Party Integration