Creating EQS Test in C++

Here’s code we’ve had but haven’t used in quite sometime so I can’t confirm it works in 4.16. Last tested using 4.14.


#pragma once
#include "EnvironmentQuery/EnvQueryTest.h"
#include "EnvQueryTest_ProjectTest.generated.h"

class PROJECT_API UEnvQueryTest_ProjectTest : public UEnvQueryTest
	virtual void RunTest(FEnvQueryInstance& QueryInstance) const override;

	virtual FText GetDescriptionTitle() const override;
	virtual FText GetDescriptionDetails() const override;


#include "Project.h"
#include "EnvironmentQuery/Items/EnvQueryItemType_VectorBase.h"
#include "EnvQueryTest_ProjectTest.h"

UEnvQueryTest_ProjectTest::UEnvQueryTest_ProjectTest(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
	//DistanceTo = UEnvQueryContext_Querier::StaticClass();
	Cost = EEnvTestCost::Low;
	ValidItemType = UEnvQueryItemType_VectorBase::StaticClass();

void UEnvQueryTest_ProjectTest::RunTest(FEnvQueryInstance& QueryInstance) const
	//Test code

FText UEnvQueryTest_ProjectTest::GetDescriptionTitle() const
	return FText::FromString(FString::Printf(TEXT("ProjectTest")));

FText UEnvQueryTest_ProjectTest::GetDescriptionDetails() const
	return DescribeFloatTestParams();
1 Like

I have decided to create a new EQS test. However, when I create a new EnvQueryTest class and compile, it immediately gives me errors, supposedly in the file EnvQueryTypes. I’m sure the error does not lie in that file, as the errors only appear with my new eqs test file present. I’m not sure what needs to be done to make it at least compile.

I have copied the includes of an example test, the EnvQueryTest_Overlap. I have implemented the constructor and the RunTest method (empty body for now), yet it still throws errors.

It would be nice if someone could post a custom, empty, but compiling EQS test and how one should generally approach this kind of task: creating a c++ class without knowing what it needs to run. The C++ API seems pretty simple and not really helpful.

What compiler errors are you getting? What’s your build.cs file look like?

Here a screenshot of the errors:

My build file has AIModule included, so it shouldn’t be that.

Thank you, I’ve tested this but it still doesn’t work… still throwing the same errors as before, but I’ve also found another one that was only visible in VS that might play into this one.

Here it is:

I don’t know though why I wouldn’t have sufficient rights. Also, those errors are weird since they don’t get shown when my own test doesn’t exist. It really is annoying… I haven’t written a lot of C++ code for UE4 yet, because every single time I attempt to do something in C++ beyond the usual C++ tutorial content, I get behavior like this. It makes me feel lost because even the most basic content doesn’t work like it should.

Commenting to bump:
I have downloaded 4.14.3 and it indeed works there. Seems like it’s a problem with 4.16.

I hope any staff member can answer or someone who has managed to make those tests run under 4.16…

I have found extremely weird behaviour, someone might be able to explain this.
I had edited the EnvQueryTypes.h earlier to add a new struct, but then removed it afterwards, resulting in a diff of a single empty line; a comment (and everything after it) was moved down by one line.

This single difference seems to be responsible, but I can not see how, since it’s just an empty line and a comment.
If I remove that empty line it compiles just fine. But how is that possible? Compilers are ignoring comments afaik, and empty lines shouldn’t be doing anything anyway.

Screenshot with added empty line after a re-build of the entire solution:

Screenshot with removed empty line (basically the original file of the engine) after re-build of the entire solution:

The difference is visible from line 452 onwards. Hope this gets cleared up.