# Right way of passing parameters to EQS after running it from "Run EQSQuery" node

**URL:** <https://forums.unrealengine.com/t/right-way-of-passing-parameters-to-eqs-after-running-it-from-run-eqsquery-node/473470>\
**Category:** AI\
**Tags:** Behavior-Tree, EQS, unreal-engine, question\
**Created:** [October 25, 2020, 3:26pm UTC](https://forums.unrealengine.com/t/right-way-of-passing-parameters-to-eqs-after-running-it-from-run-eqsquery-node/473470 "2020-10-25T15:26:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abaddon999](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Abaddon999](https://forums.unrealengine.com/u/Abaddon999)\
**Post date:** [October 25, 2020, 3:26pm UTC](https://forums.unrealengine.com/t/right-way-of-passing-parameters-to-eqs-after-running-it-from-run-eqsquery-node/473470/1 "2020-10-25T15:26:30Z")

</div>

Hello, I’m trying to figure out how to pass parameters to a EQS Query when I’m calling it from a behaviour tree task with the “Run EQSQuery” node. When I put a “Set Named Param” node right after the “Run EQSQuery” node UE freezes my whole computer when I run the game.

If I could store multiple locations generated by the EQS Query on a blackboard key (an array of vectors type variable would be needed but didn’t find how to make a BB key into an array) I could call the Query from the behaviour tree and simply tie the EQS Query parameter to a BB value instead of having to call a node from the BTTask blueprint. But I didn’t find a way to do this.

In the following link there are a screenshot of the BT, and one of the BTTask: [https://imgur.com/a/O0tP4nv](https://imgur.com/a/O0tP4nv)

Maybe I’m missing something obvious, but I don’t know. Any help would be welcome! And thanks in advance.

---

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [October 5, 2023, 1:38am UTC](https://forums.unrealengine.com/t/right-way-of-passing-parameters-to-eqs-after-running-it-from-run-eqsquery-node/473470/2 "2023-10-05T01:38:21Z")

</div>

putting this here since is the 1st thread i found, and found nothing else to help.

i really really wish epic could improve this.

apparently there are two ways (at least).

1. binding a property to a query param. then setting the query param on the behavior tree. this seems ideal but not all properties allows binding. (looking at you generate around actor).

> [@EQS Query Parameters](https://forums.unrealengine.com/t/eqs-query-parameters/52377):
>
> As you can see from the image below: There is absolutely no support on this subject anywhere. I have tried several ways to figure this out but have failed to find the correct way. Question is, does anyone know how to use the Query Parameters feature so that I can pass in different values to my generator so that I can make my Query more versatile? Ultimately I would like to pass a float value from the Run EQS Query node to change the search radius of my generator. Thanks!

1. creating your own eqs context. which is poorly documented and very inflexible, hard to maintain, and potentially much slower.  
specially if you need/like to use blackboard values, which you should since that’s why the bb exists.  
you’ll probably have to do many sub-optimal casts.

since the instance of the context is not editable in the eqs window, you can’t really set properties. this means you’d need one class per specific value you wanna read and hard-code many stuff. :´(

> **[EQS Node Reference: Contexts](https://docs.unrealengine.com/5.3/en-US/eqs-node-reference-contexts-in-unreal-engine/)**
>
> Describes how Contexts are used within Tests and Generators in the EQS system.

this is the closest but it’s incomplete

> [@How to make a UEnvQueryContext that allows you to pull data from the Blackboard?](https://forums.unrealengine.com/t/how-to-make-a-uenvquerycontext-that-allows-you-to-pull-data-from-the-blackboard/361240/4):
>
> Sorry for the delay, but I have all the details now. Since “contexts” in engine-supplied tests and generators are just classes rather than class instances there’s no way to currently get direct blackboards support. However, here’s what can be done. Classes in UE4 can be marked so that when required they’ll be created and edited “in line”, just add a EditInlineNew keyword to UCLASS definition (adding collapseCategories won’t hurt neither). To take advantage of this functionality one needs to ad…

how to get a bb value from the query

> [@How to get Blackboard Value from Query Owner?](https://forums.unrealengine.com/t/how-to-get-blackboard-value-from-query-owner/447173):
>
> Hi, I’m completely new to programming with C++ in UE4 but since I need a lot of AI I can’t just do everything in Blueprints. So I’m using the Environment Query System to get Actors of a specific Class but I need to perform some extra tests within the generator so I created a custom generator based an the ActorsOfClass one. Now I need to check a Blackboard bool value inside this generator and there seems to be a queryowner which should be the AIController I guess. But how do I get the Blackboar…

basically:

- inherit from UEnvQueryContext
- implement

```cpp
virtual void ProvideContext(FEnvQueryInstance& QueryInstance, FEnvQueryContextData& ContextData) const override

```

then inside do

```cpp

UObject* const QuerierObject = QueryInstance.Owner.Get();
AActor* ResultingActor = NULL;
// ----- your logic ---- 
// store the result only if it's a valid actor, otherwise the FEnvQueryContextData will think it succeeded 
// and proceed with the query
if (ResultingActor)
{
	UEnvQueryItemType_Actor::SetContextHelper(ContextData, ResultingActor);
}

```

in “your logic” you can do something like (please check for nulls or it might crash)

```cpp
ACharacter* const QuerierActor = Cast<ACharacter>(QuerierObject);
AAIController* const contr = Cast<AAIController>(QuerierActor->GetController());
UBlackboardComponent* const bb = contr->GetBlackboardComponent();
UObject* const Object = bb->GetValueAsObject(KeyName); 
AActor* const TargetActor = Cast<AActor>(Object);
if (TargetActor) ResultingActor = TargetActor;

```

---

<div class="post-metadata">

**Author:** ![lab-one](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lab-one/32/780274_2.png) [@lab-one](https://forums.unrealengine.com/u/lab-one)\
**Post date:** [July 25, 2024, 10:00am UTC](https://forums.unrealengine.com/t/right-way-of-passing-parameters-to-eqs-after-running-it-from-run-eqsquery-node/473470/3 "2024-07-25T10:00:41Z")

</div>

It is worth adding that in in 5.4 you can create Blueprint based context provider for your EQS.

Create an instance of EnvQuertContext\_BlueprintBase

 ![UE_Forum_BP_Context](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/9/2/69207b6c8398c97b57082585ba7680a88f60add9.png)

Override function ProvideSingleLocation, where you can extract BB data from your querier actor.

 ![UE_Forum_BP_Context_2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/f/9/0f9bead78cf02761a643d995ce6d439acc4fff9a.png)

And then you can place your newly created context blueprint into your EQS.

 ![UE_Forum_BP_Context_3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/a/7/fa7721dc8122b1eec9fd8f364c95cbf195c8a65d.png)
