In order to both locate valid melee targets and interactable actors like switches and doors, I’m looking for a way to assemble, at need, a list of actors within a certain cone or spherical radius of the player. The way I was originally planning on doing it was to place a trigger volume around the player, check overlapping actors to get a list of nearby objects whenever they try to attack or use something, then use logic custom to the combat or interaction classes to determine which nearby object was the best match.
However, it seems like in a lot of ways, that’s rebuilding functionality that already exists in pawn sensing and AI perception. I’m just starting to learn both systems, and I know they’re intended for NPC senses, but is there any particular reason why I shouldn’t use the same system for player senses, or favor my original overlap sphere over this?
Have you seen the experimental ‘Environmental Query System’?
It looks to be pretty much built for what you’re asking, and according to Mieszko Zielinski (Senior AI programmer at Epic) it’s fairly mature under-the-hood but needs a lot of work on the UI side of things, have a watch of his description of the functionality at - YouTube
This is awesome, I’m playing with it now, and a bit confused on configuration: is the intent to have a single EQS testing pawn, and multiple contexts that are attached to each player and bot? That might be a problem for me, as I have gigantic procedural levels, so figuring out where to place EQS testers to accurately see the entire landscape could become problematic.
As far as I know the EQS Testing Pawn is just to help you author the queries in the editor, they’re not for actually using in your game content.
Instead Blueprint (at least in 4.8) offers the ‘Run EQSQuery’ node which can run a specified query from the perspective of the character, or I think it’s possible to call them as part of a Behavior Tree.
I can’t give details on the BT version though, playing with BTs is tonight’s UE4 task.
Do you happen to know if there’s a C++ function call that can access the same functionality as the Run EQSQuery node? My whole project is in C++ thus far, so it’d be nice if I could figure out how to use EQS as a black box- queries go out, TLists come in.
There is, have a read through “EnvQueryManager.h”
(Useful hint- when you need the C++ version of a Blueprint node create an empty BP, add the node, right click and choose “Goto Code Definition”. Your C++ editor will open on the right class to read through.)
That is an excellent protip, think you!!