# BehaviotTree does not use the given keys 

**URL:** <https://forums.unrealengine.com/t/behaviottree-does-not-use-the-given-keys/2529057>\
**Category:** Programming & Scripting\
**Tags:** Behavior-Tree, unreal-engine, keyboard, editor, question\
**Created:** [May 26, 2025, 6:26pm UTC](https://forums.unrealengine.com/t/behaviottree-does-not-use-the-given-keys/2529057 "2025-05-26T18:26:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![omjoiknop](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@omjoiknop](https://forums.unrealengine.com/u/omjoiknop)\
**Post date:** [May 26, 2025, 6:26pm UTC](https://forums.unrealengine.com/t/behaviottree-does-not-use-the-given-keys/2529057/1 "2025-05-26T18:26:22Z")

</div>

![Снимок экрана 2025-05-26 231600](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/6/6/966c701d5f90707e784d20dbbea81c9bf6c997c1.png)  
 ![Снимок экрана 2025-05-26 231615](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/f/b/efb3baf1fa20e9768d338bab93182d0a6ef22d6a.png)  
 ![Снимок экрана 2025-05-26 231632](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/8/6/e862963970fe60b8fcacc39c4d23a7d08686e337.png)  
 ![Снимок экрана 2025-05-26 231749](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/4/2/1428502f62447158e26a6aac9a8effa6bead45f7.png)  
 ![Снимок экрана 2025-05-26 231803](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/8/b/08b8f5c6b0db8988ff363165c5df3fcce8af0d4a.png)  
I did everything according to the tutorial, the author succeeded, but I didn’t, as always.

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [May 26, 2025, 6:38pm UTC](https://forums.unrealengine.com/t/behaviottree-does-not-use-the-given-keys/2529057/2 "2025-05-26T18:38:38Z")

</div>

Use this instead “literals”

.H

```auto
UPROPERTY(EditAnywhere) 
FBlackboardKeySelector TargetActor;

```

.CPP

```auto
void UMyClass::InitializeFromAsset(UBehaviorTree& Asset)
{
	Super::InitializeFromAsset(Asset);
 
	UBlackboardData* BBAsset = GetBlackboardAsset();
	if (ensure(BBAsset))
	{
		TargetActor.ResolveSelectedKey(*BBAsset);;
	}
}

```

```auto

void UMyClass::Whatever()
{
`UObject *Object = BlackboardComponent->GetValueAsObject(TargetActor.SelectedKeyName);`
}

```

---

<div class="post-metadata">

**Author:** ![omjoiknop](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@omjoiknop](https://forums.unrealengine.com/u/omjoiknop)\
**Post date:** [May 27, 2025, 6:16am UTC](https://forums.unrealengine.com/t/behaviottree-does-not-use-the-given-keys/2529057/3 "2025-05-27T06:16:40Z")

</div>

Sorry, I’m still a newbie, I didn’t quite understand, should .h be replaced in AIPatrolController.h, and cpp in AIPatrolController.cpp or what?

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [May 27, 2025, 4:27pm UTC](https://forums.unrealengine.com/t/behaviottree-does-not-use-the-given-keys/2529057/4 "2025-05-27T16:27:06Z")

</div>

Nop. You must create a new Task Class…

```auto
`class UMyTask : public UBTTaskNode`

//Or Service:
`class UMyService : public UBTService`

//Or Decorator
class UMyDecorator : public UBTDecorator

```

This is the way i use to get a reference to the blackboard variable.

`FBlackboardKeySelector AnyVariableInBlackboard;`

this is the way to initialize it

> [@Ivan3z](#):
>
> ```auto
> void UMyClass::InitializeFromAsset(UBehaviorTree& Asset)
> {
> Super::InitializeFromAsset(Asset);
>  
> UBlackboardData* BBAsset = GetBlackboardAsset();
> if (ensure(BBAsset))
> {
> AnyVariableInBlackboard.ResolveSelectedKey(*BBAsset);
> }
> }
> 
> ```

and this is the way to get a pointer to the object

> [@Ivan3z](#):
>
> `UObject *Object = BlackboardComponent->GetValueAsObject(AnyAariableInBlackboard.SelectedKeyName);`

* * *

Take at look at this

[All about BTTasks in C++ – The Games Dev](https://www.thegames.dev/?p=70)
