Created
December 16, 2018 04:52
-
-
Save oiehot/df4a5d8c5969207fba22edaadd09ef6b to your computer and use it in GitHub Desktop.
AAPawn.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ABPawn.h" | |
AABPawn::AABPawn() | |
{ | |
PrimaryActorTick.bCanEverTick = true; | |
Capsule = CreateDefaultSubobject<UCapsuleComponent>(TEXT("CAPSULE")); | |
Mesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("MESH")); | |
Movement = CreateDefaultSubobject<UFloatingPawnMovement>(TEXT("MOVEMENT")); | |
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SPRINGARM")); | |
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("CAMERA")); | |
RootComponent = Capsule; | |
Mesh->SetupAttachment(Capsule); | |
SpringArm->SetupAttachment(Capsule); | |
Camera->SetupAttachment(SpringArm); | |
Capsule->SetCapsuleHalfHeight(88.0f); | |
Capsule->SetCapsuleRadius(34.0f); | |
Mesh->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, -88.0f), FRotator(0.0f, -90.0f, 0.0f)); | |
SpringArm->TargetArmLength = 600.0f; | |
SpringArm->SetRelativeRotation(FRotator(-20.0f, 0.0f, 0.0f)); | |
static ConstructorHelpers::FObjectFinder<USkeletalMesh> SK_CARDBOARD(TEXT("/Game/InfinityBladeWarriors/Character/CompleteCharacters/SK_CharM_Cardboard.SK_CharM_Cardboard")); | |
if (SK_CARDBOARD.Succeeded()) | |
{ | |
Mesh->SetSkeletalMesh(SK_CARDBOARD.Object); | |
} | |
Mesh->SetAnimationMode(EAnimationMode::AnimationBlueprint); | |
static ConstructorHelpers::FClassFinder<UAnimInstance> WARRIOR_ANIM(TEXT("/Game/Book/Animations/WarriorAnimBlueprint.WarriorAnimBlueprint_C")); | |
if (WARRIOR_ANIM.Succeeded()) { | |
Mesh->SetAnimInstanceClass(WARRIOR_ANIM.Class); | |
} | |
} | |
void AABPawn::BeginPlay() | |
{ | |
Super::BeginPlay(); | |
//Mesh->SetAnimationMode(EAnimationMode::AnimationSingleNode); | |
//UAnimationAsset* AnimAsset = LoadObject<UAnimationAsset>(nullptr, TEXT("/Game/Book/Animations/WarriorRun.WarriorRun")); | |
//if (AnimAsset != nullptr) { | |
// Mesh->PlayAnimation(AnimAsset, true); | |
//} | |
} | |
void AABPawn::Tick(float DeltaTime) | |
{ | |
Super::Tick(DeltaTime); | |
} | |
void AABPawn::UpDown(float NewAxisValue) | |
{ | |
AddMovementInput(GetActorForwardVector(), NewAxisValue); | |
} | |
void AABPawn::LeftRight(float NewAxisValue) | |
{ | |
AddMovementInput(GetActorRightVector(), NewAxisValue); | |
} | |
void AABPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) | |
{ | |
Super::SetupPlayerInputComponent(PlayerInputComponent); | |
ABLOG(Warning, TEXT("InputComponent: %s"), *PlayerInputComponent->GetName()); | |
PlayerInputComponent->BindAxis(TEXT("UpDown"), this, &AABPawn::UpDown); | |
PlayerInputComponent->BindAxis(TEXT("LeftRight"), this, &AABPawn::LeftRight); | |
} | |
void AABPawn::PostInitializeComponents() | |
{ | |
Super::PostInitializeComponents(); | |
ABLOG(Warning, TEXT("Pawn: %s"), *GetName()); | |
} | |
void AABPawn::PossessedBy(AController* NewController) | |
{ | |
Super::PossessedBy(NewController); | |
ABLOG(Warning, TEXT("Pawn:%s <- Controller:%s"), *GetName(), *NewController->GetName()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment