Choose your operating system:
Windows
macOS
Linux
Within the Environment Query System (EQS), Contexts provide a frame of reference for any Tests or Generators used. A Context can be as simple as the Querier (who is performing the Test) or more complex such as All Actors of a Type. A Generator, such as a Points: Grid, can use a Context that returns multiple locations or Actors. This will create a grid (of the defined size and density) at the location of each Context. In addition to Engine supplied Contexts, you can create custom Contexts in Blueprint with the EnvQueryContext_BlueprintBase class or through C++ code.
EnvQueryContext_Item
Items are created by the Generator, and if using the EQS Testing Pawn, they are the spheres that appear in the Editor. An EnvQueryContext_Item is either a location (FVector) or an Actor (AActor).
EnvQueryContext_Querier
The Querier is the Pawn that is currently possessed by an AI Controller and is executing the Behavior Tree that initiated the Environment Query. An example of where Querier as the Context could be used is if you want to search the environment around the AI character for an item they can use, or to find a place that provides cover from the player, or just to determine the current location of the AI performing the query.
In the Details panel for a Generator type, you can assign the Querier as a Context for the following properties:
Generator |
Property |
---|---|
Actors of Class |
Search Center
|
Current Location |
Query Context
|
Points: Circle |
Circle Center
|
Points: Cone |
Center Actor
|
Points: Donut |
Center
|
Points: Grid |
Generate Around
|
Points: Pathing Grid |
Generate Around
|
EnvQueryContext_BlueprintBase
You can create a custom Context through Blueprint using the EnvQueryContext_BlueprintBase Class. This provides four functions that can be overridden, enabling you to add your own custom Contexts for use within Tests in a query.
To use a custom Context:
Create a new Blueprint of the EnvQueryContext_BlueprintBase class.
In EnvQueryContext_BlueprintBase, click Override and select the type of function you wish to use.
Refer to the table below a description of each function override:
Function |
Description |
---|---|
Provide Single Location |
This returns a single location (vector). How you generate that location is up to you. For example, the function below will return the trace hit location of a random Actor (one that is found in the DesiredObjectType array, such as Pawn, Vehicle) found within 1500 cm of the Querier: |
Provide Single Actor |
This returns a single Actor. You can obtain that Actor through any method you desire. In this example, the function will return Player 0's controlled Actor: |
Provide Locations Set |
This returns an array of locations (vectors). How you generate these locations is up to you. In the example below, this function will trace from 16 evenly spaced locations on a circle with a radius of 1500 units, returning successful hits on the environment: |
Provide Actors Set |
This returns an array of Actors. You can use any desired method to obtain those Actors. In the example below, we use a Get All Actors of Class node to retrieve our specified class as the Actors to return: |