// Fill out your copyright notice in the Description page of Project Settings. #include "EnemyController.h" #include "Enemy.h" #include "BehaviorTree/BehaviorTree.h" #include "BehaviorTree/BehaviorTreeComponent.h" #include "BehaviorTree/BlackboardComponent.h" AEnemyController::AEnemyController() { BlackboardComponent = CreateDefaultSubobject(TEXT("BlackboardComponent")); check(BlackboardComponent); BehaviorTreeComponent = CreateDefaultSubobject(TEXT("BehaviorTreeComponent")); check(BehaviorTreeComponent); } void AEnemyController::OnPossess(APawn* InPawn) { Super::OnPossess(InPawn); if (!InPawn) return; if (AEnemy* Enemy = Cast(InPawn)) { if (Enemy->GetBehaviorTree()) { BlackboardComponent->InitializeBlackboard(*(Enemy->GetBehaviorTree()->BlackboardAsset)); } } }