BehaviotTree does not use the given keys






I did everything according to the tutorial, the author succeeded, but I didn’t, as always.

Use this instead “literals”

.H

UPROPERTY(EditAnywhere) 
FBlackboardKeySelector TargetActor;

.CPP

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

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

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?

Nop. You must create a new Task Class…

`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

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


Take at look at this

All about BTTasks in C++ – The Games Dev