EQS
EQS
#Overview
name: EQS
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of EQS (Environment Query System) is to provide a flexible and powerful tool for spatial reasoning and decision-making in game environments. It is a core component of Unreal Engine’s AI module, allowing developers to create complex queries to gather information about the game world and make informed decisions based on that data.
EQS is primarily used by the AI module in Unreal Engine. Based on the provided callsites, we can see that it’s utilized in the AISystem, EQSTestingPawn, and EnvQueryManager classes, which are all part of the AI subsystem.
The value of the EQS variable is typically set by calling UEnvQueryManager::GetCurrent(World), which retrieves the current instance of the EnvQueryManager for a given world.
EQS interacts with several other variables and systems, including:
- UEnvQuery (query templates)
- FEnvQueryRequest (for running queries)
- FEnvQueryInstance (for managing query instances)
- EEnvQueryRunMode (to specify how queries should be executed)
Developers should be aware of the following when using EQS:
- EQS needs to be properly initialized and available in the world before use.
- Query templates must be created and findable by name.
- EQS operations are often asynchronous, so results may not be immediately available.
- The system supports various querying modes and can handle multiple simultaneous queries.
Best practices when using EQS include:
- Always check if EQS is valid before using it (as seen in the provided code snippets).
- Use appropriate error handling and logging when queries fail or templates are not found.
- Properly manage query instances, especially in long-running or frequently updated scenarios.
- Utilize the EQSTestingPawn for debugging and visualizing queries in the editor.
- Be mindful of performance implications when running complex or frequent queries, especially in large environments or with many AI actors.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEngine.ini:3247, section: [GameplayDebuggerSettings]
- INI Section:
GameplayDebuggerSettings
- Raw value:
False
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/AISystem.cpp:190
Scope (from outer to inner):
file
function void UAISystem::RunEQS
Source code excerpt:
APlayerController* MyPC = OuterWorld->GetGameInstance()->GetFirstLocalPlayerController();
UEnvQueryManager* EQS = GetEnvironmentQueryManager();
if (Target && MyPC && EQS)
{
const UEnvQuery* QueryTemplate = EQS->FindQueryTemplate(QueryName);
if (QueryTemplate)
{
EQS->RunInstantQuery(FEnvQueryRequest(QueryTemplate, Target), EEnvQueryRunMode::AllMatching);
}
else
{
MyPC->ClientMessage(FString::Printf(TEXT("Unable to fing query template \'%s\'"), *QueryName));
}
}
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/EnvironmentQuery/EQSTestingPawn.cpp:237
Scope (from outer to inner):
file
function void AEQSTestingPawn::MakeOneStep
Source code excerpt:
void AEQSTestingPawn::MakeOneStep()
{
UEnvQueryManager* EQS = UEnvQueryManager::GetCurrent(GetWorld());
if (EQS == NULL)
{
return;
}
if (QueryInstance.IsValid() == false && QueryTemplate != NULL)
{
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/EnvironmentQuery/EQSTestingPawn.cpp:254
Scope (from outer to inner):
file
function void AEQSTestingPawn::MakeOneStep
Source code excerpt:
}
}
QueryInstance = EQS->PrepareQueryInstance(QueryRequest, QueryingMode);
if (QueryInstance.IsValid())
{
EQS->RegisterExternalQuery(QueryInstance);
}
}
// possible still not valid
if (QueryInstance.IsValid() == true && QueryInstance->IsFinished() == false)
{
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/EnvironmentQuery/EnvQueryManager.cpp:244
Scope (from outer to inner):
file
function void UEnvQueryManager::NotifyAssetUpdate
Source code excerpt:
if (World)
{
UEnvQueryManager* EQS = UEnvQueryManager::GetCurrent(World);
if (EQS)
{
EQS->InstanceCache.Reset();
}
// was as follows, but got broken with changes to actor iterator (FActorIteratorBase::SpawnedActorArray)
// for (TActorIterator<AEQSTestingPawn> It(World); It; ++It)
for (TActorIterator<AActor> It(World); It; ++It)
{