-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAICharacter.cpp
52 lines (41 loc) · 1.32 KB
/
AICharacter.cpp
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 "Project.h"
#include "MyAIController.h"
#include "BehaviorTree/BehaviorTree.h"
#include "Perception/PawnSensingComponent.h"
#include "AICharacter.h"
// Sets default values
AAICharacter::AAICharacter()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
PawnSensingComp = CreateDefaultSubobject<UPawnSensingComponent>(TEXT("PawnSensingComp"));
PawnSensingComp->SetPeripheralVisionAngle(90.0f);
}
// Called when the game starts or when spawned
void AAICharacter::BeginPlay()
{
Super::BeginPlay();
if (PawnSensingComp)
{
PawnSensingComp->OnSeePawn.AddDynamic(this, &AAICharacter::OnSeePlayer);
}
}
// Called every frame
void AAICharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AAICharacter::OnSeePlayer(APawn * Pawn)
{
AMyAIController* AIController = Cast<AMyAIController>(GetController());
if (AIController) {
GLog->Log("Hello there");
AIController->SetSeenTarget(Pawn);
}
}
/*Called to bind functionality to input
void AAICharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}*/