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

Defining Generators for Spatial Data Sampling

Students will implement EQS generators to create grids, points, or actor-based locations for the AI to analyze within the world.

In this lesson, you will learn how to define EQS Generators to procedurally sample spatial points in your game world for AI decision-making.

The Role of the Generator

While an Environmental Query System (EQS) test ranks points, the Generator is the engine that creates the initial set of points for your AI to evaluate. Think of the Generator as the "scout" that finds potential locations, while the Tests act as the "critics" that filter them based on your criteria.

Types of Spatial Sampling

When you add a Generator to an Environment Query, you choose how the system populates the area around the AI. Common strategies include:

  • Points: Grid: Creates a uniform layout of points within a box or circle. This is perfect for searching an open area to find cover or a vantage point.
  • Points: Circle: Generates points in a radial pattern around an origin (like the AI's current position). You can define the number of rings and the density of points.
  • Actors: All Actors of Class: Instead of arbitrary coordinates, this generator samples the locations of specific actors (e.g., all BP_HealthPack instances or all CoverPoint actors) in the level.

Implementation Example

When you select a generator in the EQS editor, you must define the Origin. The origin acts as the anchor for the sampling pattern. You can set the Origin to Context: Querier (the AI actor itself) or Context: Item (another object).

For instance, to find a place to hide, you might use a Points: Circle generator:

  1. Set the Circle Center to Querier.
  2. Adjust Radius to determine how far the AI can move to find cover.
  3. Set Space Between to manage performance; a smaller number yields more points but consumes more CPU during the query.

By configuring these parameters, you ensure that the AI only spends its time "thinking" about points that are actually relevant to its current behavioral context.

Key Takeaway: Generators define the "search space" for your AI, and by choosing the right spatial pattern—be it a grid, circle, or actor-list—you determine exactly where the AI looks for its next action.