Create AI `TaskFireWeapon` node
This commit is contained in:
parent
bf742b0224
commit
e77b6cce35
|
@ -0,0 +1,20 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#include "TaskFireWeapon.h"
|
||||||
|
#include "EnemyAIController.h"
|
||||||
|
|
||||||
|
EBTNodeResult::Type UTaskFireWeapon::ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory)
|
||||||
|
{
|
||||||
|
auto enemyController = Cast<AEnemyAIController>(owner.GetAIOwner());
|
||||||
|
auto enemyPawn = Cast<AEnemyCharacter>(enemyController->GetPawn());
|
||||||
|
auto blackboardComponent = owner.GetBlackboardComponent();
|
||||||
|
auto playerCharacter = Cast<APlayerCharacter>(blackboardComponent->GetValueAsObject(TargetActor.SelectedKeyName));
|
||||||
|
|
||||||
|
if (enemyPawn && playerCharacter)
|
||||||
|
{
|
||||||
|
enemyPawn->OnFire();
|
||||||
|
return EBTNodeResult::Succeeded;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EBTNodeResult::Failed;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "BehaviorTree/BTTaskNode.h"
|
||||||
|
#include "TaskFireWeapon.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class NAKATOMI_API UTaskFireWeapon : public UBTTaskNode
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Options", Meta = (AllowPrivateAccess = "true", DisplayName = "Target Actor Key"))
|
||||||
|
FBlackboardKeySelector TargetActor;
|
||||||
|
|
||||||
|
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& owner, uint8* memory) override;
|
||||||
|
|
||||||
|
};
|
Loading…
Reference in New Issue