Behavior Designer

This page describes integration support for Behavior Designer. The Dialogue System's support package provides methods to control Behaviour Designer from within conversations and sequences. Behavior Designer itself has a corresponding support package that allows you to monitor and control the Dialogue System from within behavior trees. (Behavior Designer is required.)

Behavior Designer copyright © Opsive.


How to Set Up Behavior Designer Support

To enable Behavior Designer support in the Dialogue System:

  1. Download and import the Behavior Designer actions for the Dialogue System, which are maintained by Opsive: http://www.opsive.com/assets/BehaviorDesigner/samples.php
  2. Import the package Third Party Support/Behavior Designer Support.

Behavior Tree Lua Bridge

The Behavior Tree Lua Bridge component synchronizes a behavior tree's shared variables with the Dialogue System's Lua environment. Attach it to the GameObject that contains the behavior tree. To do this, select the GameObject and then menu item Component > Dialogue System > Third Party > Behavior Designer > Behavior Tree Lua Bridge.

Synchronization occurs automatically at the beginning and end of conversations. You can also synchronize manually by calling SyncToLua() or SyncFromLua(). Only bools, floats, ints, and strings are synchronized.

The Lua variables will have the name gameObjectName_variableName. All blank spaces and hyphens will be converted to underscores.

For example, say an NPC named Private Hart has a behavior tree with a shared variable named Angry. The Lua variable will be Variable["Private_Hart_Angry"].

You can check the value of Variable["Private_Hart_Angry"] in a dialogue entry's Conditions fields and set the value a User Script field.


Behavior Designer Sequencer Commands

The support package adds two sequencer commands. You can use these commands within conversations, barks, and other sequences to control behavior trees.


Behavior()

Note: Provided in Scripts/Third Party Support/Behavior Designer. Requires Behavior Designer.

Syntax: Behavior(subject, start|stop|pause|resume)

Description: Controls a Behavior Designer behavior tree.

Parameters:

  • subject: The name of a GameObject containing a behavior tree, or speaker or listener. The behavior tree can be located on a child object.
  • start|stop|pause|resume: Control action for the behavior tree.
    • start: Starts or restarts the behavior tree.
    • stop: Stops the behavior tree.
    • pause: Pauses the behavior tree.
    • resume: Resumes the behavior tree if paused.

Example:

  • Behavior(Sergeant Graves, start) (Starts the behavior tree on Sergeant Graves)
  • Behavior(Terminal, pause) (Pauses the behavior tree on Terminal)

BehaviorVariable()

Note: Provided in Scripts/Third Party Support/Behavior Designer. Requires Behavior Designer.

Syntax: BehaviorVariable(subject, variableName, value)

Description: Sets the value of a behavior tree's shared variable.

Parameters:

  • subject: The name of a GameObject containing a behavior tree, or speaker or listener. The behavior tree can be located on a child object.
  • variableName: The name of a shared variable on the behavior tree. These variable types are supported: Bool, Float, Int, String, GameObject, Object, Transform, Vector3.
  • value: The new value of the variable.

Example:

  • BehaviorVariable(Sergeant Graves, target, speaker) (On Sergeant Graves' behavior tree, sets the variable target to the speaker)
  • Behavior(Terminal, overheating, true) (On Terminal's behavior tree, sets the variable overheating to true)

<< Third Party Support