Hi, I am writing a custom test fo filter out an actor of a particular type. I have added the AIModule and the EQS generator i am using is the generate Actors around Context. The output log gives the following warning :
LogEQS:Warning: Query [FindTargetSoldier] can’t use test [FindAttackingSoldierTest_0] in option 0 [], removing it
The code:
FindTargetSoldier.h
#pragma once
#include "EnvironmentQuery/EnvQueryTest.h"
#include "FindAttackingSoldierTest.generated.h"
/**
*
*/
UCLASS()
class CHILDNOMORE_API UFindAttackingSoldierTest : public UEnvQueryTest
{
GENERATED_BODY()
UPROPERTY(EditDefaultsOnly, Category = Trace)
TSubclassOf<UEnvQueryContext> Context;
virtual void RunTest(FEnvQueryInstance& QueryInstance) const override;
virtual FText GetDescriptionTitle() const override;
virtual FText GetDescriptionDetails() const override;
virtual void PostLoad() override;
};
DECLARE_LOG_CATEGORY_EXTERN(YourLog, Log, All);
FindTargetSoldier.cpp
#include "ChildNoMore.h"
#include "FindAttackingSoldierTest.h"
#include"EngineUtils.h"
#include"SoldierCharacter.h"
#include "Engine.h"
DEFINE_LOG_CATEGORY(YourLog);
void UFindAttackingSoldierTest::RunTest(FEnvQueryInstance& QueryInstance) const
{
//Now go thrui the queries
UE_LOG(YourLog, Warning, TEXT("RINNONG TEST"));
GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::White, FString("TESTING!!!!"));
float MinThresholdValue = FloatValueMin.GetValue();
float MaxThresholdValue = FloatValueMax.GetValue();
TArray<AActor*> ActorsInQuery;
QueryInstance.GetAllAsActors(ActorsInQuery);
TArray<FVector> ContextLocations;
if (!QueryInstance.PrepareContext(Context, ContextLocations))
{
GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::White, FString("TESTING!!!!"));
return;
}
for (FEnvQueryInstance::ItemIterator It(this, QueryInstance); It; ++It)
{
if (Cast<ASoldierCharacter>(GetItemActor(QueryInstance,*It)))
{
It.SetScore(TestPurpose, FilterType, 0.75f, MinThresholdValue, MaxThresholdValue);
}
GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::White, FString("TESTING!!!!"));
}
}
FText UFindAttackingSoldierTest::GetDescriptionTitle() const
{
return FText::FromString(FString("FIND SOLDIER"));
}
FText UFindAttackingSoldierTest::GetDescriptionDetails() const
{
return FText::FromString("SOldier test");
}
void UFindAttackingSoldierTest::PostLoad()
{
Super::PostLoad();
}