In this lesson, you will learn how to use Unreal Engine’s built-in EQS visualization tools to inspect spatial samples and diagnose performance bottlenecks during live gameplay.
When your AI’s Environmental Query System (EQS) isn't behaving as expected—perhaps it’s selecting a suboptimal cover point or failing to find a valid location—you need to look "under the hood" to see exactly how it evaluates the environment.
Enabling Visual Debugging
To see the EQS in action, start the game in the editor (PIE) and press the apostrophe (') key to open the AI Debugger. Once open, press 4 to switch to the EQS view. You will see a list of all active or recently run queries on the left. Selecting a query highlights the spatial samples in the viewport:
- Colored Spheres: These represent the generated locations. Green indicates a high score, while red indicates a low score.
- Ray Traces: If you use Trace tests, you’ll see lines extending from the AI or towards the target, allowing you to identify if a trace is hitting geometry (like a wall or invisible collision) unexpectedly.
Troubleshooting Performance
EQS queries can be expensive if you generate too many samples or run them on every frame. If your frame rate drops when an AI starts searching, check the EQS Debugger for these red flags:
- High Sample Counts: If the generator is creating thousands of points, look for ways to decrease the density or restrict the radius.
- Excessive Scoring: If a specific test is taking a long time, check your Scoring Equation. Avoid overly complex math inside a test; if possible, normalize your data early so the EQS doesn't have to perform heavy calculations for every single sample.
- Over-Running Queries: Ensure your Behavior Tree is not triggering an EQS query every tick. If you see the query flashing rapidly in the debugger, increase the wait time or use a Service with a longer interval to trigger the query less frequently.
By observing the visual feedback, you can immediately spot if a test is failing because of a trace collision or an incorrect weight setting, allowing for rapid iteration.
Key Takeaway: Use the AI Debugger (Key '4') to visually inspect sample scores and trace results, ensuring that your queries are both accurate and performant.