-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefender_Player_Controller.cpp
46 lines (35 loc) · 1.02 KB
/
Defender_Player_Controller.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
#include "Defender_Player_Controller.h"
#include "Kismet/GameplayStatics.h"
#include "Camera/CameraActor.h"
#include "Defender.h"
ADefender_Player_Controller::ADefender_Player_Controller()
{
}
void ADefender_Player_Controller::BeginPlay()
{
TArray<AActor*> CameraActors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ACameraActor::StaticClass(), CameraActors);
FViewTargetTransitionParams Params;
SetViewTarget(CameraActors[0], Params);
}
void ADefender_Player_Controller::SetupInputComponent()
{
Super::SetupInputComponent();
EnableInput(this);
InputComponent->BindAxis("MoveCircular", this, &ADefender_Player_Controller::MoveCircular);
InputComponent->BindAction("Shoot", IE_Pressed, this, &ADefender_Player_Controller::Shoot);
}
void ADefender_Player_Controller::MoveCircular(float AxisValue)
{
auto MyPawn = Cast<ADefender>(GetPawn());
if (MyPawn) {
MyPawn->MoveCircular(AxisValue);
}
}
void ADefender_Player_Controller::Shoot()
{
auto MyPawn = Cast<ADefender>(GetPawn());
if (MyPawn) {
MyPawn->Shoot();
}
}