[4.5] Bug (or feature?) in EQS

Yeah, I know that EQS is super experimental, so I don’t expect quick fix.

Anyway, I have query which finds a position for AI, from where he can shoot player. I want to get the closest location from player character, from which eye contact is possible. EQ looks like this:

It used to work well in UE 4.4. I believe that the problem arise with optimization in EnvQueryInstance.cpp introduced in commit https://github.com/EpicGames/UnrealEngine/commit/c18a424666268bd409c441197d445d5f4e0576d7.

From my understanding the idea is, that if the last test is filter, we don’t need to test all items. It is sufficient to take the current best item and test it. If it passes the test, we are done, otherwise second best item is tested, etc.

The problem is that items are not sorted between tests, so instead of taking the current best item, the last test just takes first generated item. As a result the distance check in my example has no effect.

Can someone give me advice, how to work around this issue, preferably without changing engine code? Or maybe I don’t understand the code correctly and I’m just doing something wrong?

I’ve found a workaround by myself. Changing “Test purpose” on trace test from “Filter” to “Score” (with high weight), disables said optimization. It has to test all items, but at lest it works.

Hi there,

Thanks a lot for reporting this. This is indeed a bug, That’s right, items don’t get sorted while the query is run, but in the “single item” mode (which is the case now, where we just want to get a single item out) items should get sorted before the final filter is run.

I’ve filed it as UE-4596, with Major priority (we’re using EQS internally quite a bit!)

Thanks again!

–mieszko

On second thought, there was a bug like that in EQS that I think has been fixed after the 4.5 version has branched from the master branch. Would you mind checking if you experience the bug in UE4 master branch? I’m unable to repro it locally.

–mieszko

Thanks for your answer. Looking at the code in master branch, it seems that the problem I’m experiencing is indeed fixed. I’ll test it after the weekend.