# How to properly use EQS with AI

**URL:** <https://forums.unrealengine.com/t/how-to-properly-use-eqs-with-ai/1991657>\
**Category:** Programming & Scripting\
**Tags:** EQS, unreal-engine, Blueprint, CPP\
**Created:** [August 25, 2024, 9:05pm UTC](https://forums.unrealengine.com/t/how-to-properly-use-eqs-with-ai/1991657 "2024-08-25T21:05:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Voxiit](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/voxiit/32/1217475_2.png) [@Voxiit](https://forums.unrealengine.com/u/Voxiit)\
**Post date:** [August 25, 2024, 9:05pm UTC](https://forums.unrealengine.com/t/how-to-properly-use-eqs-with-ai/1991657/1 "2024-08-25T21:05:48Z")

</div>

Hi everyone,

I’m currently experimenting with AI and the Environment Query System.  
So far, I’ve done the UE5 tutorial for both and I wanted to go futher but I’m stuck and I don’t know if I’m doing things on the right way.

The tutorial of the EQS, teachs you how to use the grid in order to find a position for the AI to be able to see the player and to move to that position.

Here’s my current Behavior Tree and my Blackboard.

 ![1 - my behavior tree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/6/d/f6d4b8253cc098447fe39ab790c1ab588df787d4.jpeg)  
 ![2 - my blackboard](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/e/3/7e3cae9443374e5a117866b6d378a13e7b4982b5.jpeg)

Her’s my EQS Query.

 ![3 - my eqs](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/d/a/bdad90c3f8a6b3eb518bbb350d4f6ef3a5fced37.jpeg)

And here’s my EQS context (I’ve done it on C++).

 ![4 - my context cpp](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/7/c/57cc8e0a7ff27fe0ee73aa23e476970f092bbd8f.jpeg)

What I want to do is to use the EQS to locate specific actors on the map (Pick Ups that I’ve created) so the AI can move move to the closest one. But I don’t want the EQS to simply return to me a Vector as it was the case in the UE tutorial, I want it to return to me the Object that is found, my Pick Up.  
That’s why you can see that in my Behavior Tree, on the **Run EQS Query** Node, I set the Result Blackboard Key to **PickUp** which is an Object instead of **MoveToLocation** which is a Vector.

Unfortunalty, the **EQS Query** isn’t able to set the **PickUp** Blackboard Key. If I run my code, my **PickUp** value will remain invalid, even though the **PickUpActor** is found in my C++ function.

So I’m wondering. Am I using the EQS right ?  
Should it be used to get a reference to an object or should I do it with a regular task ?  
If the EQS can do such a thing, could you please tell me what I’m doing wrong ?  
I’d really love to experimentate more on AI but I struggle to get started and I would love to have some help please.

Thank you for your time.

---

<div class="post-metadata">

**Author:** ![Voxiit](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/voxiit/32/1217475_2.png) [@Voxiit](https://forums.unrealengine.com/u/Voxiit)\
**Post date:** [December 1, 2024, 2:22pm UTC](https://forums.unrealengine.com/t/how-to-properly-use-eqs-with-ai/1991657/3 "2024-12-01T14:22:00Z")

</div>

Hi.

I’ve found my answer and forgot to close this question.  
In order to locate an Actor, you need to use **GetActorsOfClass** instead of **SimpleGrid**.  
Hope it’ll help someone in the future.  
Bye.

 ![epic](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/7/0/d70f4625f87aa777fd1613dcf900d29c5326caa8.jpeg)
