// As the matter of BeginPlay alone, a directly converted implementation looks like this :
In .h
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
AActor* Enemy;
In .cpp
void BeginPlay()
{
Super::BeginPlay();
UBlackboardComponent* const pBlackboard =
UAIBlueprintHelperLibrary::GetBlackboard(this);
if(!pBlackboard) return;
Enemy = UGameplayStatics::GetPlayerController(pBlackboard->(),0);
pBlackboard->SetValueAsObject(TEXT("Enemy"), Enemy);
}
Then again, you would have to start thinking on: Where is my blackboard get instantiated. Spawn in the blueprint? One may think it is not pretty, so may do like this because we don’t like the BlueprintHelperLibrary here.
In .h
// Edit on main blueprints only. After spawned the instance, it is technically useless
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
TSubclassOf<UBlackboardComponent> BlackboardTemplate;
// The actual instance, we use the data here.
UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite)
UBlackboardComponent* BlackboardInstance;
In .cpp
void BeginPlay()
{
Super::BeginPlay();
BlackboardInstance =
NewObject<UBlackboardComponent>(this, BlackboardTemplate);
if(!BlackboardInstance) return;
Enemy = UGameplayStatics::GetPlayerController(BlackboardInstance ->(),0);
BlackboardInstance->SetValueAsObject(TEXT("Enemy"), Enemy);
}
Above just examples. UE4 maybe spawn one for you. I never deal with BB, so this is just a format to follow, may contains compile error. Alternatively, find a way to grab the reference by all means.