Formations Pack for Behavior Designer Pro
The Formations Pack is an add-on for Behavior Designer Pro that allows you to create various formation patterns for groups of agents. While the pack contains 15 built-in formations the system is design to be easily extendable for any formation type. The default set of Formations Pack tasks use Unity’s navigation mesh to traverse the world. The Formations Pack doesn’t do the actual movement – it instead sets the destination for the underlying pathfinding implementation (Unity’s NavMesh, A* Pathfinding Project, etc).
Adding a New Formation
Add Task to your Behavior Tree
- In your behavior tree, right-click and select Add Task.
- Navigate to the Formations Pack category or type the name of the formation task that you want add.
- Choose one of the available formation types.
Changing the Pathfinder
Configure the Formation Base Settings
Formation Group Settings
- Is 2D: Is this formation being used in a 2D space?
- Formation Group ID: Integer that defines which group this agent belongs to.
- Force Leader: When enabled, this agent will be forced as the leader of the group.
Leader Settings
- Target Position: The position the formation will move to.
- Formation Direction: How the formation should be oriented:
- Transform Direction: Uses the leader’s forward direction.
- Movement Direction: Uses the direction from current position to target.
- Specified: Uses a custom vector you define.
- Specified Direction: Forward direction if using “Specified” orientation.
- Move To Initial Formation: If enabled, agents first create the formation before moving.
- Fail On Agent Removal: If enabled, the task fails if any agent leaves the formation.
- Update Unit Locations On Agent Removal: If enabled, formation positions update when agents leave.
Formation Settings
- Rotation Speed: Degrees per second agents rotate.
- Rotation Threshold: Angle threshold for stopping rotation.
- Out Of Range Distance Delta: Distance at which an agent is considered out of range.
- In Range Distance Delta: Distance at which an agent is considered back in range.
- Out Of Range Speed Multiplier: Speed adjustment for out-of-range agents.
- Stuck Duration: Time with zero velocity before agent is considered stuck.
- Stop On Task End: Whether to stop movement when the task ends.
Configure Formation-Specific Settings
Formation Groups
Setting Up Formation Groups
Basic Setup
- Assign the same Formation Group ID to all agents in a formation.
- The first agent added becomes the leader by default.
- Alternatively, set Force Leader on an agent to make it the leader.
Using Multiple Groups
- Assign different Formation Group ID values to create separate formations.
- Each group operates independently with its own leader and target position.
Formation Start Delay
Creating a Custom Formations
- Inherit from FormationsBase.
- Implement the abstract CalculateFormationPosition method.
- Define formation-specific parameters.
- Override additional methods for special behavior.
Below is an example implementation:
using Opsive.BehaviorDesigner.AddOns.FormationsPack.Runtime.Tasks; using UnityEngine; public class MyFormation : FormationsBase { /// <summary> /// Should the optimal indicies be assigned? This should be set to false for random formations. /// </summary> public override bool AssignOptimialIndicies => true; /// <summary> /// Calculate the position for this agent in the skirmisher formation. /// </summary> /// <param name="index">The index of this agent in the formation.</param> /// <param name="totalAgents">The total number of agents in the formation.</param> /// <param name="center">The center position of the formation.</param> /// <param name="forward">The forward direction of the formation.</param> /// <param name="samplePosition">Should the position be sampled?</param> /// <returns>The position for this agent.</returns> public override Vector3 CalculateFormationPosition(int index, int totalAgents, Vector3 center, Vector3 forward, bool samplePosition) { return Vector3.zero; } }