Dual Behaviors Handling
Several Behaviors require a Context Behavior to be active at the same time to be properly run.
This is the case when an Entity runs:
- GoTo Behavior: a Navigation Behavior must be running to avoid other navigating Entities.
- Steer Behavior: a Flock Behavior must be running to avoid other flocking Entities (Boids).
The easiest way to handle those pairs of behaviors is to use a Parallel Operator containing them: this will ensure that both behaviors are running at the same time (unless some specific Start/Stop Triggers are set, obviously).
For instance, if dealing with a Go To Behavior, this can be done by creating a Parallel operator then adding the Go To Behavior and a Navigation Behavior to it (or just by drag-and-dropping any of the Behaviors on the other one, as shown here).
If others behaviors must be run after the GoTo Behavior, it is necessary to properly configure the Parallel Operator by setting its exit mode to "As soon as one behavior as ended" value; otherwise the Parallel Operator will remain active as the Navigation Behavior has not ended.
In general, several different Behaviors are performed successively, and the required Context Behavior must be running during the entire simulation time. A better way to handle this is to use a Parallel Operator containing:
- The Context Behavior
- A Behavior Container processing the other Behaviors
Let's consider the case of driving an Entity to a target position, then back to its origin position. This can be done using a sequence of 2 GoTo Behavior (each configured with a different target) :
Instead of putting each GoTo behavior in a Parallel Operator with a Navigation Behavior, let's only build a Parallel Operator containing a single Navigation Behavior (that will be use by all GoTo Behaviors used by the Entity) and a Behavior Container (that will contain the GoTo Behaviors sequence described above):
Also see Behavior Editor controls to know how to easily navigate in Behavior Containers hierarchy.