11. Creating the FindPlayer EQS

Create an Environment Query that finds all instances of the player's TopDownCharacter in the level.

On this page

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


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

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


    Which will create the ActorsOfClass Generator like so:


  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.


    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:


    • 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


    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)


And that's it!

Select Skin

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback