Course contentsShow
← Unreal Engine Game Development
Lesson 435 of 8806. AI, Navigation, and Decision MakingFree lesson

Executing EQS Queries from Behavior Trees

Students will integrate the Run EQS Query task into behavior trees to trigger dynamic spatial analysis during AI execution.

In this lesson, you will learn how to bridge your spatial analysis logic by triggering Environmental Query System (EQS) requests directly from your Behavior Tree execution flow.

The Role of the Run EQS Task

While you have already built sophisticated queries using Generators and Tests, they currently sit idle in the editor. To make your AI actually "ask" the environment a question, you use the Run EQS Query task. This task acts as the messenger: it tells the AI to perform a specific query, waits for the results, and saves the "winner" (the best-scoring location or actor) into a Blackboard key for the AI to act upon.

Integrating the Query

To integrate this into your Behavior Tree:

  1. Add the Task: Inside your Behavior Tree, drag from a Sequence or Selector and add the Run EQS Query task node.
  2. Configure the Node: Select the task node and look at the Details panel. You must assign the EQS Query Template you previously authored.
  3. Blackboard Binding: The most important step is the Query Config section. You must set the Blackboard Key property to a Vector or Object type. When the query completes, the AI will automatically write the coordinates of the highest-scoring item into this variable.

For example, if your AI needs a "Safe Hiding Spot," your EQS test will find the location with the highest "Distance to Enemy" score. The Run EQS Query task will store that specific coordinate into a Blackboard key named TargetHidingSpot. Your subsequent "Move To" node can then use that same Blackboard key as its destination.

Why This Matters

This workflow decouples what the AI wants to find from how it reaches that location. You keep your Behavior Tree clean by delegating complex spatial reasoning to the EQS, while the Behavior Tree manages the high-level logic of when that analysis should occur. By placing the Run EQS Query node before a "Move To" node in a Sequence, you ensure the AI always calculates the most relevant position just before it begins its journey.

Key Takeaway: The Run EQS Query task turns static spatial analysis into dynamic AI behavior by piping the winning result of an Environmental Query directly into your Blackboard for immediate use by movement or action tasks.