Add StoreActorLocationTask AI Task Node

This commit is contained in:
Louis Hobbs 2023-08-23 00:20:02 +01:00
parent f0b8c594d4
commit 6d8169e2b3
2 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,29 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "StoreActorLocationTask.h"
#include "NakatomiCharacter.h"
#include "BehaviorTree/BlackboardComponent.h"
UStoreActorLocationTask::UStoreActorLocationTask()
{
}
EBTNodeResult::Type UStoreActorLocationTask::ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory)
{
auto blackboardComponent = owner.GetBlackboardComponent();
auto playerCharacter = Cast<ANakatomiCharacter>(blackboardComponent->GetValueAsObject(TargetActor.SelectedKeyName));
if (playerCharacter)
{
blackboardComponent->SetValueAsVector(TargetActorLocation.SelectedKeyName, playerCharacter->GetActorLocation());
return EBTNodeResult::Succeeded;
}
return EBTNodeResult::Failed;
}
EBTNodeResult::Type UStoreActorLocationTask::AbortTask(UBehaviorTreeComponent& owner, uint8* memory)
{
return EBTNodeResult::Aborted;
}

View File

@ -0,0 +1,33 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/BTTaskNode.h"
#include "StoreActorLocationTask.generated.h"
/**
*
*/
UCLASS()
class NAKATOMI_API UStoreActorLocationTask : public UBTTaskNode
{
GENERATED_BODY()
private:
UPROPERTY()
UBehaviorTreeComponent* behaviourTreeOwner = nullptr;
UPROPERTY(EditAnywhere, Meta = (AllowPrivateAccess = "true"))
FBlackboardKeySelector TargetActor;
UPROPERTY(EditAnywhere, Meta = (AllowPrivateAccess = "true"))
FBlackboardKeySelector TargetActorLocation;
public:
UStoreActorLocationTask();
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
virtual EBTNodeResult::Type AbortTask(UBehaviorTreeComponent& owner, uint8* memory) override;
};