-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBTTask_Shoot.cpp
More file actions
28 lines (22 loc) · 923 Bytes
/
Copy pathBTTask_Shoot.cpp
File metadata and controls
28 lines (22 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Fill out your copyright notice in the Description page of Project Settings.
#include "BTTask_Shoot.h"
#include "AIController.h"
#include "ShooterCharacter.h"
UBTTask_Shoot::UBTTask_Shoot()
{
NodeName = "Shoot";
}
EBTNodeResult::Type UBTTask_Shoot::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
Super::ExecuteTask(OwnerComp, NodeMemory);
if (OwnerComp.GetAIOwner() == nullptr) {// to get the hold of ai controller then from ai controller we gove have the acess of the player pawn
return EBTNodeResult::Failed;
}
AShooterCharacter* Character = Cast<AShooterCharacter>(OwnerComp.GetAIOwner()->GetPawn());//get pawn return the pointer that value of the pawn or the character that our ai controller is controlling
if (Character == nullptr) {
return EBTNodeResult::Failed;
}
//now we can call the shoot
Character->Shoot();
return EBTNodeResult::Succeeded;
}