# AI: How to get the Closest Pawn using EQS for a Multiplayer Game?

**URL:** <https://forums.unrealengine.com/t/ai-how-to-get-the-closest-pawn-using-eqs-for-a-multiplayer-game/340423>\
**Category:** AI\
**Tags:** ai-navigation, EQS, unreal-engine, Multiplayer, question\
**Created:** [December 3, 2015, 5:22pm UTC](https://forums.unrealengine.com/t/ai-how-to-get-the-closest-pawn-using-eqs-for-a-multiplayer-game/340423 "2015-12-03T17:22:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![firstplayer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@firstplayer](https://forums.unrealengine.com/u/firstplayer)\
**Post date:** [December 3, 2015, 5:22pm UTC](https://forums.unrealengine.com/t/ai-how-to-get-the-closest-pawn-using-eqs-for-a-multiplayer-game/340423/1 "2015-12-03T17:22:03Z")

</div>

As the title states, how do I get the closest pawn to the AI using EQS for a multiplayer game?

---

<div class="post-metadata">

**Author:** ![Ecnassianer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ecnassianer](https://forums.unrealengine.com/u/Ecnassianer)\
**Post date:** [April 20, 2018, 6:11pm UTC](https://forums.unrealengine.com/t/ai-how-to-get-the-closest-pawn-using-eqs-for-a-multiplayer-game/340423/2 "2018-04-20T18:11:26Z")

</div>

The EQS documentation shows how to set up environment queries:  
[https://docs.unrealengine.com/en-us/Engine/AI/EnvironmentQuerySystem/QuickStart](https://docs.unrealengine.com/en-us/Engine/AI/EnvironmentQuerySystem/QuickStart)

, create a context that finds all the actors of your pawn class.

 ![238278-actorsset.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/1/8/31827a4e85dd3851fb2dbef6f0b8d9c6ca334f9b.jpeg)

Then you just need an environment query that generates a simple grid around the querier and has a Distance filter that checks for the distance to your closest pawn context.

 ![238276-eqc.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/e/1/6e18d7a7e118d45db4c6ded9a5dd2361331853f8.jpeg)
