EQS Node Reference: Contexts

Describes how Contexts are used within Tests and Generators in the EQS 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

Querier_SearchCenter.png

Current Location

Query Context

Querier_CurrentLocation.png

Points: Circle

Circle Center

Querier_Circle.png

Points: Cone

Center Actor

Querier_Cone.png

Points: Donut

Center

Querier_Donut.png

Points: Grid

Generate Around

Querier_Grid.png

Points: Pathing Grid

Generate Around

Querier_PathingGrid.png

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:

  1. Create a new Blueprint of the EnvQueryContext_BlueprintBase class.
    BlueprintBase_Create.png

  2. In EnvQueryContext_BlueprintBase, click Override and select the type of function you wish to use.
    BlueprintBase_Function.png

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:

ProvideSingleActor.png

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:

ProvideActorsSet.png

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback