EQS queries running asynchronously creating issues

Hi there,

I have a bunch of EQS queries and while results are produced in the finished function, it doesnt show up in the main function because it is waiting to finish.

This is the function calling the eqs query

EnemySeekerQueryRequest = FEnvQueryRequest(StructQuery.EQSQuery, EnemySquad->SquadLeader);
EnemySeekerQueryRequest.Execute(EEnvQueryRunMode::SingleResult, this, &URA_SquadController::EnemySeekerQueryFinished);

if (tempsquad->OptimalLocation != FVector::ZeroVector)
{

			break;

}

And this is the one processing the results

FVector resultlocation= Result->GetItemAsLocation(0);

tempsquad->OptimalLocation = resultlocation;

Issue is that OptimalLocation is always zero because the results dont get to it after execution of the Query. How do I wait for the query to finish before checking the result? As I understand EQS queries are executed asynchronously.

you can’t, you’ll have to handle the logic somehow else, probably in the callback from the EQS (EnemySeekerQueryFinished)

Thanks for your answer @zeaf .

Any suggestions on how to handle this?

just move the logic using the EQS results to EnemySeekerQueryFinished

I see break, so I’m assuming you need to run the EQS for multiple structures and you need to wait for all of them to be done before performing some logic. I guess that’s a bit more complex, you’ll probably have to somehow keep track of all the EQS, and maybe increment a counter when each is done, and only perform the logic once the counter reaches the total number of EQS Requests made