11. Creating the FindPlayer EQS

Choose your OS:

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

Steps

  1. To start, double click the FindPlayer Environment Query asset in the Content Browser.

    findPlayerAsset.png

    Which will open the Environment Query editor which will look like this:

    startingEQ.png

    The Environment Query editor works almost exactly like the Behavior Tree editor.

  2. Right-click into the Update Graph area, and select ActorsOfClass from the Context menu:

    createGetActors.png

    Which will create the ActorsOfClass Generator like so:

    cga_made.png

  3. 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.

    connected.png

    There can only be one Generator per Environment Query

  4. Next, setup the ActorsOfClass node by selecting it, and changing its Search Radius and Searched Actor Class properties:

    aoc_details.png

    • Search Radius = 1500

    • Searched Actor Class = TopDownCharacter.

    This Generator finds all the Actors of the given Class, within the radius, and creates Items from them.

  5. Add a Trace test to the ActorsOfClass node

    addTraceTest.png

    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)

  6. 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)

    aoc_TraceFinal.png

And that's it!