Using EQS to report a SUCCESSFUL trace only?

I’m trying to use the Environment Query System to do some simple stuff and I feel like I must be missing something obvious because the trace check seems useless to me.

Here’s the basic idea: I want an enemy AI to try and find a position where he will have line of sight to the player, and move to that position to shoot the player.

So I create an EQS Context which returns all actors of class MyCharacter (the player BP), and I place a MyCharacter BP in the map in-editor so the EQS Testing Pawn will have something to refer to.

Then I create a new environment query. I have it generate a pathing grid around the enemy with large spacing and large distance (I use 300 spacing and 3000 distance). Then I do a trace test.

I’ve tried all of the options and nothing seems to work properly. What I want to do is trace from each item to the player (or I suppose FROM the player, it doesn’t matter to establish line of sight), so I use my custom EQS Context to establish the player pawn as a context. I set it up to trace on the visibility channel; this all makes sense.

Problem is, ALL SPOTS return valid hits, because the engine is checking for a trace which hits ANYTHING, not just the player. Okay, no big deal, flip the bool flag and tell it to look for spots where the trace doesn’t hit. But then this doesn’t work either, because the player himself blocks on the visbility channel! Any spot with clear line of sight to the player will fail the “no hit” test because the player is hit by the trace.

In other words, what function could the Trace filter possibly HAVE? I would imagine that in something close to 100% of cases, you want to determine if the Querier can see a certain Context… But if the engine has no way of separating traces which stop AT the context and traces which stop before they REACH the context, what can you do with the trace filter? And more to the point, how do you create a test which checks for line of sight using EQS, if not with the trace function?

Well, UE4 crashed, and I opened it back up and tried to recreate what I had, and now it works. The game successfully traces on visibility from the player pawn to each generated Item and only reports those traces which return no hits (meaning that there is line of sight to the item).

I have no idea what, if anything, I did differently this time, but I guess it was just some sort of stupidity on my end.