EQS c++ programmatically output results

Trying to follow through Unreal Engine: Environment Query System (EQS) in C++ – Think And Build
However, I need to do as much of this through c++ as possible, since I will be using my own AI to interpret and respond to the results of the queries. From the tutorial, I see that I need a behaviortree in order to instantiate an EQS, then tests to filter results from the generator. What I need to be able to do (and the unreal api doesn’t seem to provide documentation on) is how to take the results that have been tested for, and programatically output them, say through a fmessageendpoint to somewhere else.

So my questions are:

Can an eqs be attached to an actorcomponent, say, an unreal vehicle in the normal way? The goal here would be to on ticktimer, execute the query in a sphere around the actor it’s attached to.

How are tests actually built in c++?
(I did find this, but it only answers a very specific question. I’d really like to see the method’s api Creating EQS Test in C++ - AI - Epic Developer Community Forums)

Does anyone have any further links to test building in c++? I’ve googled and read through 4 or 5 tutorials in full and maybe 20 other related results but they all seem to be very bare bones and without an API I really can’t figure out how to do what I want. Unreal’s docs is a blueprint based item which isn’t useful to me in the slightest. I need to understand how it works, not which buttons to click on the editor to make it happen

How resource intensive would it be to continuously run a generator, or alternatively, is there another method to obtain the information i need?

Thank you in advance.

Hi,

is how to take the results that have
been tested for, and programatically
output them, say through a
fmessageendpoint to somewhere else.

what do you mean? So do you mean how to get the end result of an EQS query or do you mean how to get all the results in between each test?

Hi, thanks for taking the time to respond.
I suppose i’d like the freedom to look at all the results, intermediate and otherwise, in order to decide what to do with them. Is that an option?

Ok, then

I suppose i’d like the freedom to look
at all the results, intermediate and
otherwise, in order to decide what to
do with them. Is that an option?

if you just want to look at the intermediary results for like debugging/understanding purposes then I use the EQS testing pawn for that (shows you the items and their scores in the viewport) Environment Query Testing Pawn | Unreal Engine Documentation

So you would create a new blueprint inheriting from EQSTestingPawn, put that into the world and set the EQS query you want to visualize.


I see that I need a behaviortree in
order to instantiate an EQS, then
tests to filter results from the
generator.

You don’t need a behavior tree to run EQS queries, you can do that from BP and C++ as well, so I don’t see any problem with running EQS queries inside an actor component. Ofc I wouldn’t run them on tick, since they may/will take longer than a single frame to execute.

As for tests in C++, I looked through the source code how the existing tests where build and learned from that. So I suggest you start from what is in your link, then look through the existing tests to build on that.


How resource intensive would it be to
continuously run a generator

Not quite sure what you mean. I mean you only run the generator when you run the EQS query. As for performance cost of EQS queries, that depends on what logic you execute there (e. g. pathfinding test will be more costly than just distance test). For the exact numbers you could use the profiler.

@chrudimer

As for tests in C++, I looked through the source code how the existing tests where build and learned from that. So I suggest you start from what is in your link, then look through the existing tests to build on that.

The source code in question is only what is provided in the tutorial (linked above), and includes just four files. I’ve seen tests in blueprints, i’ve not seen any tests in c++, and the api is bare bones. Any links you’ve got either to git repos or the like, doesn’t have to be a tutorial. They offer a single test, with nothing to tell me ‘what else is out there.’
As an aside, It seems like a lot of people just slap things together with blueprints which, (it seems) is a really awful way to do any kind of change tracking. Even producing c++ with Blueprint’s codegen’d produces awful, messy stuff that I could never put in a git repo.

Not quite sure what you mean. I mean you only run the generator when you run the EQS query. As for performance cost of EQS queries, that depends on what logic you execute there (e. g. pathfinding test will be more costly than just distance test). For the exact numbers you could use the profiler.

Good advice – can you point me to a tutorial on the profiler? never seen or used it before, so unsure which one you’re referring to.

Sorry for being unclear, I meant the source code of unreal engine =)

I don’t remember whether I needed to do something to get the source code into visual studio but I think it was just there. So for example you could search for and open UEnvQueryTest.h / .cpp and some of its children and take a look at those.


As for the profiler Profiler Tool Reference | Unreal Engine Documentation and How to improve game thread CPU performance in Unreal Engine - Unreal Engine

Also when you open any EQS query in the editor you also have a Profiler tab. If its not there you can open it via Window->Profiler

Great, thanks for all your help, much appreciated. I’ve marked this answer as correct.

I don’t understand do you mean how to get the end result of an EQS query or do you mean how to get all the results in between each test?