Character Model
- Character Model : 인간형 Pawn을 좀 더 효과적으로 제작하기 위한 특수한 모델
ACharacter 클래스
UCLASS()
class ARENABATTLE_API AABCharacter : public ACharacter
{
// ...
UPROPERTY(VisibleAnywhere, Category = Camera)
USpringArmComponent* SpringArm;
UPROPERTY(VisibleAnywhere, Category = Camera)
UCameraComponent* Camera;
private:
void UpDown(float NewAxisValue);
void LeftRight(float NewAxisValue);
// ...
AABCharacter::AABCharacter()
{
// 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;
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SPRINGARM"));
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("CAMERA"));
SpringArm->SetupAttachment(GetCapsuleComponent());
Camera->SetupAttachment(SpringArm);
GetMesh()->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, -88.0f), FRotator(0.0f, -90.0f, 0.0f));
SpringArm->TargetArmLength = 400.0f;
SpringArm->SetRelativeRotation(FRotator(-15.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())
{
GetMesh()->SetSkeletalMesh(SK_CARDBOARD.Object);
}
GetMesh()->SetAnimationMode(EAnimationMode::AnimationBlueprint);
static ConstructorHelpers::FClassFinder<UAnimInstance> WARRIOR_ANIM(TEXT("/Game/Book/Animations/WarriorAnimBlueprint.WarriorAnimBlueprint_C"));
if (WARRIOR_ANIM.Succeeded())
{
GetMesh()->SetAnimInstanceClass(WARRIOR_ANIM.Class);
}
// ...
}
void AABCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis(TEXT("UpDown"), this, &AABCharacter::UpDown);
PlayerInputComponent->BindAxis(TEXT("LeftRight"), this, &AABCharacter::LeftRight);
}
void AABCharacter::UpDown(float NewAxisValue)
{
AddMovementInput(GetActorForwardVector(), NewAxisValue);
}
void AABCharacter::LeftRight(float NewAxisValue)
{
AddMovementInput(GetActorForwardVector(), NewAxisValue);
}
컨트롤 회전 적용
UCLASS()
class ARENABATTLE_API AABCharacter : public ACharacter
{
// ...
void LookUp(float NewAxisValue);
void Turn(float NewAxisValue);
// ...
void AABCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
// ...
PlayerInputComponent->BindAxis(TEXT("Turn"), this, &AABCharacter::Turn);
PlayerInputComponent->BindAxis(TEXT("LookUp"), this, &AABCharacter::LookUp);
}
// ...
void AABCharacter::LookUp(float NewAxisValue)
{
AddControllerPitchInput(NewAxisValue);
}
void AABCharacter::Turn(float NewAxisValue)
{
AddControllerPitchInput(NewAxisValue);
}
삼인칭 모드
UCLASS()
class ARENABATTLE_API AABCharacter : public ACharacter
{
// ...
void SetControlMode(EControlMode NewControlMode);
void AABCharacter::SetControlMode(EControlMode NewControlMode)
{
//SpringArm->TargetArmLength = 450.0f;
//SpringArm->SetRelativeRotation(FRotator::ZeroRotator);
ArmLengthTo = 450.0f;
SpringArm->bUsePawnControlRotation = true;
SpringArm->bInheritPitch = true;
SpringArm->bInheritRoll = true;
SpringArm->bInheritYaw = true;
SpringArm->bDoCollisionTest = true;
bUseControllerRotationYaw = false;
GetCharacterMovement()->bOrientRotationToMovement = true;
GetCharacterMovement()->bUseControllerDesiredRotation = false;
GetCharacterMovement()->RotationRate = FRotator(0.0f, 720.0f, 0.0f);