그냥 게임개발자
ProjectA - GameMode, Character 클래스 생성 2023/12/26 본문
캐릭터 결정

추후에 모델링 바꿀 예정

Character : Character에 관련된 클래스
Game : Game에 관련된 클래스
Player : Player입력, Player데이터에 관련된 클래스


현재 캐릭터 모듈은 이렇게 두개로 만들었다.
Base는 Character를 상속 받는 클래스
Player는 Base를 상속받는 클래스
기본적인 캐릭터 설정값(기획에 따라 바뀔 수도 있음)
PACharacterBase.cpp
#include "Components/CapsuleComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
APACharacterBase::APACharacterBase()
{
// UseControllerRotation
bUseControllerRotationPitch = false;
bUseControllerRotationRoll = false;
bUseControllerRotationYaw = false;
// Capsule
GetCapsuleComponent()->InitCapsuleSize(42.f, 96.f);
GetCapsuleComponent()->SetCollisionProfileName(TEXT("Pawn"));
// Movement
GetCharacterMovement()->bOrientRotationToMovement = true;
GetCharacterMovement()->RotationRate = FRotator(0.0f, 500.0f, 0.0f);
GetCharacterMovement()->JumpZVelocity = 700.0f;
GetCharacterMovement()->AirControl = 0.35f;
GetCharacterMovement()->MaxWalkSpeed = 500.f;
GetCharacterMovement()->MinAnalogWalkSpeed = 20.f;
GetCharacterMovement()->BrakingDecelerationFalling = 2000.0f;
// Mesh
GetMesh()->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, -100.f), FRotator(0.0f, -90.f, 0.0f));
GetMesh()->SetAnimationMode(EAnimationMode::AnimationBlueprint);
GetMesh()->SetCollisionProfileName(TEXT("CharacterMesh"));
// MeshLoad
static ConstructorHelpers::FObjectFinder<USkeletalMesh> CharacterMeshRef(TEXT("캐릭터스켈레탈메쉬주소"));
if (CharacterMeshRef.Succeeded())
{
GetMesh()->SetSkeletalMesh(CharacterMeshRef.Object);
}
static ConstructorHelpers::FClassFinder<UAnimInstance> AnimInstanceClassRef(TEXT("애니메이션인스턴스주소"));
if (AnimInstanceClassRef.Succeeded())
{
GetMesh()->SetAnimInstanceClass(AnimInstanceClassRef.Class);
}
}
게임모드는 기본적으로 설정할것들만 설정
PAGameModeBase.h
APAGameMode::APAGameMode()
{
// DefaultPawnClass
static ConstructorHelpers::FClassFinder<APawn> DefaultPawnClassRef(TEXT("캐릭터 클래스 주소"));
if (DefaultPawnClassRef.Succeeded())
{
DefaultPawnClass = DefaultPawnClassRef.Class;
}
//PlayerController
static ConstructorHelpers::FClassFinder<APlayerController> PlayerControllerClassRef(TEXT("플레이어 컨트롤러 주소"));
if (PlayerControllerClassRef.Succeeded())
{
PlayerControllerClass = PlayerControllerClassRef.Class;
}
}
플레이어한테 카메라 생성
PACharacterPlayer.h
// SpringArm
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, Meta = (AllowPrivateAccess = "true"))
TObjectPtr<class USpringArmComponent> CameraBoom;
// Camera
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, Meta = (AllowPrivateAccess = "true"))
TObjectPtr<class UCameraComponent> FollowCamera;
PACharacterPlayer.cpp
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
APACharacterPlayer::APACharacterPlayer()
{
// SpringArm
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
CameraBoom->TargetArmLength = 400.0f;
CameraBoom->bUsePawnControlRotation = true;
// Camera
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
FollowCamera->bUsePawnControlRotation = false;
}
'ProjectA' 카테고리의 다른 글
ProjectA - 임시적 1인칭 Yaw회전 적용(2023/12/27) (0) | 2023.12.27 |
---|---|
ProjectA - ChangeCamera 에러 수정(2023/12/26) (1) | 2023.12.26 |
ProjectA - EnhancedInput(Move, Look)(2023/12/26) (0) | 2023.12.26 |
프로젝트명 : ProjectA(2023/12/26) (0) | 2023.12.26 |
언리얼 엔진 게임 프레임워크 (0) | 2023.12.26 |