11 - Creating the FindPlayer EQS
This is the simpler of the two Environment Queries, as all it will do is return a list of all the TopDownCharacters within 1500 units of the AI then test if the AI can see the TopDownCharacters. If it can, then we'll get our ActorToFleeFrom for our Behavior Tree.
There are a number of ways this process can be done, each with their own advantages and disadvantages. Using EQS for this means that we can add additional tests at a later time to choose the best enemy (TopDownCharacter) to run from.
Some quick glossary terms you're going to run into:
- A Generator creates Items in relation to a Context
- Items are used in Tests often in relation to a Context (how far is Item X from Context Y)
- Items are culled or scored based on the results of Tests
- To start, double click the FindPlayer Environment Query asset in the Content Browser.
Which will open the Environment Query editor which will look like this:
The Environment Query editor works almost exactly like the Behavior Tree editor.
- Right-click into the Update Graph area, and select ActorsOfClass from the Context menu:
Which will create the ActorsOfClass Generator like so:
- To connect nodes in the Environment Query editor, you just need to drag from the bottom of the Root node to the Top of the ActorsOfClass node, exactly how it is done in the Behavior Tree editor.
There can only be one Generator per Environment Query
- Next, setup the ActorsOfClass node by selecting it, and changing its Search Radius and Searched Actor Class properties:
This Generator finds all the Actors of the given Class, within the radius, and creates Items from them.
- Search Radius = 1500
- Searched Actor Class = TopDownCharacter.
- Add a Trace test to the ActorsOfClass node
Trace tests are useful to check if a Context has line of sight to an Item, in this case, our AI to the Items (TopDownCharacters/Players in this case)
- Now select the Trace Test on the ActorsOfClass node by left-clicking it, and in the Details Panel, change the Bool Match Property to false (unchecked)
And that's it!