In this lesson, you will learn how to bridge the gap between Environment Query System (EQS) spatial data and Behavior Tree logic to create AI that can react intelligently to its surroundings.
From Sensing to Selecting
While Behavior Trees handle the "what" (logic flow), EQS handles the "where" (spatial awareness). To make an AI perform a task—like finding cover—we need the Behavior Tree to trigger an EQS query and store the result in a Blackboard Key so the AI can navigate to it.
The Integration Workflow
To connect these systems, we use the Run EQS Query node directly inside our Behavior Tree.
- Define the Blackboard Key: Create a Blackboard Key of type
Vector(e.g.,TargetCoverLocation). - Add the Run EQS Query Task: Drag a
Run EQS Querynode into your Behavior Tree Sequence. - Configure the Node:
- Query Template: Select the EQS asset you designed to find cover.
- Blackboard Key: Select your
TargetCoverLocationkey. - This tells the Behavior Tree: "Run this spatial search, and once you find the best spot, save those coordinates into this Blackboard variable."
- Use the Result: Add a
MoveTonode immediately after the EQS task. Set theBlackboard Keyof theMoveTonode to the sameTargetCoverLocation.
Because the MoveTo node is now reading the value stored by the EQS task, the AI will dynamically move to the specific location identified as the "best" cover in that exact moment.
// Logic flow inside the Behavior Tree Sequence:
// 1. [Run EQS Query] -> Finds best cover, writes to "TargetCoverLocation"
// 2. [MoveTo] -> Reads "TargetCoverLocation", paths to the result
This integration allows your AI to perform complex spatial reasoning on demand. If the environment changes, the next time the Sequence runs, the EQS will update the TargetCoverLocation with new data, and the MoveTo node will automatically path toward the updated, safer position.
Key Takeaway: Integrating EQS with a Behavior Tree allows the AI to translate spatial analysis into actionable movement by writing query results directly into Blackboard keys that are consumed by movement tasks.