Create Set Focus Task
This commit is contained in:
parent
a13083e1fe
commit
408954c96d
|
@ -0,0 +1,5 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Tasks/BTTClearFocus.h"
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "BehaviorTree/BTTaskNode.h"
|
||||
#include "BTTClearFocus.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class NAKATOMI_API UBTTClearFocus : public UBTTaskNode
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
|
@ -0,0 +1,20 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "../Tasks/BTTSetFocus.h"
|
||||
|
||||
#include "BehaviorTree/BlackboardComponent.h"
|
||||
#include "Nakatomi/EnemyAIController.h"
|
||||
#include "Nakatomi/PlayerCharacter.h"
|
||||
|
||||
EBTNodeResult::Type UBTTSetFocus::ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory)
|
||||
{
|
||||
UBlackboardComponent* BlackboardComponent = owner.GetBlackboardComponent();
|
||||
UObject* actor = BlackboardComponent->GetValueAsObject(TargetActorKey.SelectedKeyName);
|
||||
APlayerCharacter* PlayerCharacter = Cast<APlayerCharacter>(actor);
|
||||
|
||||
AEnemyAIController* enemyController = Cast<AEnemyAIController>(owner.GetAIOwner());
|
||||
enemyController->SetFocus(PlayerCharacter, EAIFocusPriority::Gameplay);
|
||||
|
||||
return EBTNodeResult::Succeeded;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "BehaviorTree/BTTaskNode.h"
|
||||
#include "BTTSetFocus.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class NAKATOMI_API UBTTSetFocus : public UBTTaskNode
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, Category = "Options",
|
||||
Meta = (AllowPrivateAccess = "true", DisplayName = "Target Actor Key"))
|
||||
FBlackboardKeySelector TargetActorKey;
|
||||
|
||||
public:
|
||||
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
|
||||
|
||||
};
|
Loading…
Reference in New Issue