-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShooterAIController.cpp
More file actions
52 lines (38 loc) · 1.57 KB
/
Copy pathShooterAIController.cpp
File metadata and controls
52 lines (38 loc) · 1.57 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Fill out your copyright notice in the Description page of Project Settings.
#include "ShooterAIController.h"
#include "Kismet/GameplayStatics.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "ShooterCharacter.h"
void AShooterAIController::BeginPlay()
{
Super::BeginPlay();
APawn* PlayerPawn = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);//to get the actor to which our ai sees
if (AIBehavior != nullptr) {
RunBehaviorTree(AIBehavior);
GetBlackboardComponent()->SetValueAsVector(TEXT("StartLocation"), GetPawn()->GetActorLocation());
}
}
void AShooterAIController::Tick(float DeltaTime)
{
/*APawn* PlayerPawn = UGameplayStatics::GetPlayerPawn(GetWorld(), 0);//to get the actor to which our ai sees
SetFocus(PlayerPawn);// to set the aiming focus for the ai
if (LineOfSightTo(PlayerPawn)) {
//SetFocus(PlayerPawn);// to set the aiming focus for the ai
//MoveToActor(PlayerPawn, AcceptanceRadius);//for moving to the shooter actor
GetBlackboardComponent()->SetValueAsVector(TEXT("PlayerLocation"), PlayerPawn->GetActorLocation());
GetBlackboardComponent()->SetValueAsVector(TEXT("LastKnownPlayerLocation"), PlayerPawn->GetActorLocation());
}
else {
//ClearFocus(EAIFocusPriority::Gameplay);
//StopMovement();
GetBlackboardComponent()->ClearValue(TEXT("PlayerLocation"));
}*/
}
bool AShooterAIController::IsDead() const
{
AShooterCharacter* ControlledCharacter = Cast<AShooterCharacter>(GetPawn());
if (ControlledCharacter != nullptr) {
return ControlledCharacter->IsDead();
}
return true;
}