The .h file
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/Tasks/BTTask_BlackboardBase.h"
#include "ChasePlayer_Task.generated.h"
/**
*
*/
UCLASS()
class ZOMBIEAPOCALYPSE_API UChasePlayer_Task : public UBTTask_BlackboardBase
{
GENERATED_BODY()
public:
UChasePlayer_Task();
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override;
};
The .cpp file
// Fill out your copyright notice in the Description page of Project Settings.
#include "Tasks/ChasePlayer_Task.h"
#include "AIController.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "AITypes.h"
UChasePlayer_Task::UChasePlayer_Task()
{
NodeName = "ChasePlayerTask";
}
EBTNodeResult::Type UChasePlayer_Task::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
Super::ExecuteTask(OwnerComp, NodeMemory);
FVector GoalLocation = OwnerComp.GetBlackboardComponent()->GetValueAsVector(GetSelectedBlackboardKey());
FAIMoveRequest FAIMoveReq;
FAIMoveReq.SetGoalLocation(GoalLocation);
OwnerComp.GetAIOwner()->MoveToLocation(GoalLocation, 1.0f, true, true, true, true, NULL, true);
return EBTNodeResult::Succeeded;
}
Code did compile successfully.