- ACharactor 상속을 타고 가면 APawn 이 있다
- 캡술과 메쉬는 겟터함수를 이용해서 사용한다.
- GetMesh(), GetCapsuleComponent
- 그것 뺴곤 폰하고 일치
UCLASS(config=Game, BlueprintType, meta=(ShortTooltip="A character is a type of Pawn that includes the ability to walk around."))
class ENGINE_API ACharacter : public APawn
{
GENERATED_BODY()
public:
/** Default UObject constructor. */
ACharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
private:
/** The main skeletal mesh associated with this Character (optional sub-object). */
UPROPERTY(Category=Character, VisibleAnywhere, BlueprintReadOnly, meta=(AllowPrivateAccess = "true"))
USkeletalMeshComponent* Mesh;
/** Movement component used for movement logic in various movement modes (walking, falling, etc), containing relevant settings and functions to control movement. */
UPROPERTY(Category=Character, VisibleAnywhere, BlueprintReadOnly, meta=(AllowPrivateAccess = "true"))
UCharacterMovementComponent* CharacterMovement;
/** The CapsuleComponent being used for movement collision (by CharacterMovement). Always treated as being vertically aligned in simple collision check functions. */
UPROPERTY(Category=Character, VisibleAnywhere, BlueprintReadOnly, meta=(AllowPrivateAccess = "true"))
UCapsuleComponent* CapsuleComponent;
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/ANIM/WarriorAnimBluePrint.WarriorAnimBluePrint_C"));
if (WARRIOR_ANIM.Succeeded())
{
GetMesh()->SetAnimInstanceClass(WARRIOR_ANIM.Class);
}
}
// Called when the game starts or when spawned
void AABCharacter::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AABCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AABCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
PlayerInputComponent->BindAxis(TEXT("UpDown"),this, &AABCharacter::UpDown);
PlayerInputComponent->BindAxis(TEXT("RightLeft"), this, &AABCharacter::RightLeft);
PlayerInputComponent->BindAxis(TEXT("Turn"), this, &AABCharacter::Turn);
PlayerInputComponent->BindAxis(TEXT("LookUp"), this, &AABCharacter::LookUp);
}
void AABCharacter::UpDown(float axis)
{
AddMovementInput(GetActorForwardVector(), axis);
}
void AABCharacter::RightLeft(float axis)
{
AddMovementInput(GetActorRightVector(), axis);
}
void AABCharacter::Turn(float axis)
{
AddControllerPitchInput(axis);
}
void AABCharacter::LookUp(float axis)
{
AddControllerYawInput(axis);
}
'Unreal > Game 1 (C++)' 카테고리의 다른 글
6.3인칭 컨트롤 구현 (디아블로방식) (0) | 2019.05.02 |
---|---|
6.3인칭 컨트롤 구현 (GTA 방식) (0) | 2019.05.02 |
4.애니메이션 재생 (0) | 2019.05.02 |
3.에디터 - 폰 입력 연동, 바인딩 (0) | 2019.05.02 |
2.캐릭터에 들어가는 기본적인 항목 (0) | 2019.05.01 |