Skip to content

Instantly share code, notes, and snippets.

@ariok
Created May 20, 2019 19:10
Show Gist options
  • Save ariok/4cd10a8b87ce8109b56d9ad7736d17d3 to your computer and use it in GitHub Desktop.
Save ariok/4cd10a8b87ce8109b56d9ad7736d17d3 to your computer and use it in GitHub Desktop.
How to run EQS in C++
#include "MyAIController.h"
#include "EnvironmentQuery/EnvQueryManager.h"
void AMyAIController::FindHidingSpot()
{
FEnvQueryRequest HidingSpotQueryRequest = FEnvQueryRequest(FindHidingSpotEQS, this);
HidingSpotQueryRequest.Execute(EEnvQueryRunMode::SingleResult, this, &AMyAIController::MoveToQueryResult);
}
void AMyAIController::MoveToQueryResult(TSharedPtr<FEnvQueryResult> result)
{
if (result->IsSuccsessful()) {
MoveToLocation(result->GetItemAsLocation(0));
}
}
#include "CoreMinimal.h"
#include "AIController.h"
#include "EnvironmentQuery/EnvQueryTypes.h"
#include "MyAIController.generated.h"
class UEnvQuery;
UCLASS()
class EQSTUTORIAL_API AMyAIController : public AAIController
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, Category = "AI")
UEnvQuery *FindHidingSpotEQS;
UFUNCTION(BlueprintCallable)
void FindHidingSpot();
void MoveToQueryResult(TSharedPtr<FEnvQueryResult> result);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment