Public Member Functions | Public Attributes
RAIN.BehaviorTrees.BTParallelNode Class Reference

BTParallelNode is a behavior tree node for allowing child nodes to operate in parallel. Since Unity runs behavior single threaded, nodes are processed in priority order (pre-sorted). However, at each Execute step all active children are given an opportunity to execute even if higher priority nodes fail. More...

Inheritance diagram for RAIN.BehaviorTrees.BTParallelNode:
RAIN.BehaviorTrees.BTNode RAIN.Action.Action

List of all members.

Public Member Functions

 BTParallelNode (string nodeName)
 Constructor.
override void AddChild (BTNode child)
 AddChild adds a BehaviorTree node to the child list.
override ActionResult Start (Agent agent, float deltaTime)
 Start Action handler. If a child fails during Start, and if failOnSingle is true, then FAILURE is returned. Whether FAILURE or SUCCESS if returned, all children's states are reset to RUNNING.
override ActionResult Execute (Agent agent, float deltaTime)
 Execute loops through all children whose prior state was RUNNING and Executes them. It then calculates a return value based on failOn flags.
override ActionResult Stop (Agent agent, float deltaTime)
 Stop Action handler. All children are stopped.

Public Attributes

const string NODETYPE = "parallel"
 Node type, used in xml parsing.
bool failOnSingle = false
 Does a single failure cause the entire parallel action to fail? This is often the case if the parallel action is used to support persistent constraints as parallel conditional nodes.
bool succeedOnSingle = false
 Does a single success cause the entire parallel action to immediately succeed? This is often the case if the parallel action is used to support multiple solutions to the same problem, or to terminate if a problem is solved by some other action.
bool failOnTie = true
 If both failOnSingle is true and succeedOnSingle is true, and both happen at the same timestep, does fail win?

Detailed Description

BTParallelNode is a behavior tree node for allowing child nodes to operate in parallel. Since Unity runs behavior single threaded, nodes are processed in priority order (pre-sorted). However, at each Execute step all active children are given an opportunity to execute even if higher priority nodes fail.

Users can choose how failure or success impacts the overall node state.


Constructor & Destructor Documentation

Constructor.

Parameters:
nodeNameThe name of the node to create

Member Function Documentation

override void RAIN.BehaviorTrees.BTParallelNode.AddChild ( BTNode  child) [virtual]

AddChild adds a BehaviorTree node to the child list.

Parameters:
childThe behavior tree node to add

Reimplemented from RAIN.BehaviorTrees.BTNode.

override ActionResult RAIN.BehaviorTrees.BTParallelNode.Execute ( Agent  agent,
float  deltaTime 
) [virtual]

Execute loops through all children whose prior state was RUNNING and Executes them. It then calculates a return value based on failOn flags.

Parameters:
agentAI Agent owner of the behavior tree
deltaTimetimestep in seconds
Returns:
SUCCESS if the entire parallel action is successful, FAILURE if the entire action has failed, or RUNNING if more work remains

Reimplemented from RAIN.Action.Action.

override ActionResult RAIN.BehaviorTrees.BTParallelNode.Start ( Agent  agent,
float  deltaTime 
) [virtual]

Start Action handler. If a child fails during Start, and if failOnSingle is true, then FAILURE is returned. Whether FAILURE or SUCCESS if returned, all children's states are reset to RUNNING.

Parameters:
agentAI Agent owner of the behavior tree
deltaTimetimestep in seconds
Returns:
ActionResult

Reimplemented from RAIN.Action.Action.

override ActionResult RAIN.BehaviorTrees.BTParallelNode.Stop ( Agent  agent,
float  deltaTime 
) [virtual]

Stop Action handler. All children are stopped.

Parameters:
agentAI Agent owner of the behavior tree
deltaTimetimestep in seconds
Returns:
ActionResult, obeying failOnSingle rules

Reimplemented from RAIN.Action.Action.


Member Data Documentation

Does a single failure cause the entire parallel action to fail? This is often the case if the parallel action is used to support persistent constraints as parallel conditional nodes.

If both failOnSingle is true and succeedOnSingle is true, and both happen at the same timestep, does fail win?

const string RAIN.BehaviorTrees.BTParallelNode.NODETYPE = "parallel"

Node type, used in xml parsing.

Does a single success cause the entire parallel action to immediately succeed? This is often the case if the parallel action is used to support multiple solutions to the same problem, or to terminate if a problem is solved by some other action.