* MyCharacter 살펴보기(캐릭터->폰->액터 구조)
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;
#if WITH_EDITORONLY_DATA
/** Component shown in the editor only to indicate character facing */
UPROPERTY()
UArrowComponent* ArrowComponent;
#endif
(
- 생성자 내부
Mesh = CreateOptionalDefaultSubobject<USkeletalMeshComponent>(ACharacter::MeshComponentName);
if (Mesh)
{
Mesh->AlwaysLoadOnClient = true;
Mesh->AlwaysLoadOnServer = true;
Mesh->bOwnerNoSee = false;
Mesh->VisibilityBasedAnimTickOption = EVisibilityBasedAnimTickOption::AlwaysTickPose;
Mesh->bCastDynamicShadow = true;
Mesh->bAffectDynamicIndirectLighting = true;
Mesh->PrimaryComponentTick.TickGroup = TG_PrePhysics;
Mesh->SetupAttachment(CapsuleComponent);
static FName MeshCollisionProfileName(TEXT("CharacterMesh"));
Mesh->SetCollisionProfileName(MeshCollisionProfileName);
Mesh->SetGenerateOverlapEvents(false);
Mesh->SetCanEverAffectNavigation(false);
}
매시, 무브먼트, 캡슐등이 이미 만들어져있다. => 사용만해라
-SKeletalMesh : 뼈대를 이용해 움직일 수 있는 매쉬
-UCharacterMovementComponent : 더 복잡한 이동 가능(vs Floating) ex)쪼그리기
- UCapsuleComponent : 충돌범위
* MyCharacter를 플레이어로
1. MyPawn 에 있던 업다운 함수, 매쉬로딩, BindAxis MyCharacter에 복붙
2. 게임모드에 가서 기본폰클래스 바꿔주기
(-)단점 : 카메라 어색, 공중에떠있음
해결 : SpringArm, Camera
AMyCharacter::AMyCharacter()
{
// 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);
SpringArm->TargetArmLength = 500.f;
SpringArm->SetRelativeRotation(FRotator(-35.0f, 0.f, 0.f));
GetMesh()->SetRelativeLocationAndRotation(
FVector(0.f, 0.f, -88.f), FRotator(0.f, -90.f, 0.f));
static ConstructorHelpers::FObjectFinder<USkeletalMesh> SM(TEXT("SkeletalMesh'/Game/ParagonGreystone/Characters/Heroes/Greystone/Meshes/Greystone.Greystone'"));
if (SM.Succeeded())
GetMesh()->SetSkeletalMesh(SM.Object);
}
SpringArm을 캡슐에 달아줌(유사부모)
카메라를 스프링암에 달아줌
국룰값 설정 => 캐릭터가 땅에붙게 && 앞을보도록
* 마우스로 좌우시야 조작
void AMyCharacter::Yaw(float Value)
{
AddControllerYawInput(Value);
}
&& 엔진설정-축-Yaw-마우스 X 추가
directX : Yaw함수 직접 구현해야함 매우복잡
언리얼 : 이미 다 완성되 있음. 조립해라....
'UE5' 카테고리의 다른 글
스테이트 머신 (0) | 2022.08.14 |
---|---|
애니메이션 기초 (0) | 2022.08.14 |
블루프린트 클래스 (0) | 2022.08.11 |
게임플레이 프레임워크 (0) | 2022.08.07 |
로그와 디버깅 (0) | 2022.08.07 |