Pawn & Character
Pawn
- 플레이어나 AI가 제어할 수 있는 Actor이다.
FloatingPawnMovement 컴포넌트가 있어야 물리 함수를 적용할 수 있다.
Defualt Pawn & Player Controller 설정
World Settings 창 > Game Mode > Selected GameMode
Character
- 애니메이션 처리 등의 기능이 추가된 Pawn이다.
CapsuleComponent, CharacterMesh, CharacterMovement 컴포넌트를 가진다.
Player Controller
- 빌드 파일에서
"EnhancedInput" 의존성을 추가해야한다.
- 자체적으로 방향 데이터를 가지고 있어 Pawn에서 이를 활용할 수 있다.
회전 설정
- Pawn
Pawn > Use Controller Rotation Pitch/Yaw/Roll
- Character
- Pawn Control Rotation에 맞춰서 회전
Character Movement (Rotation Settings) > Use Controller Desired Rotation
- 움직일 때만 Pawn Control Rotation에 맞춰서 회전
Character Movement (Rotation Settings) > Orient Rotation to Movement
- SpringArm
Camera Settings > Use Pawn Control Rotation
Camera Settings > Inherit Pitch/Yaw/Roll
Gameplay Tag
Project Settings 창 > Project > GameplayTags > MageplayTagList에서 확인한다.
- 빌드 파일에서
"GameplayTags" 의존성을 추가해야한다.
- 에디터 상에서 추가하면 코드상에서 활용할 수 없다.
Asset Manager
Project Settings 창 > Engine > General Settings > Asset Manager Class에서 설정한다.
Data Asset
Content 폴더 Add > Miscellaneous > Data Asset
- Primary Data Asset
- Data Asset 여러개를 번들로 가진다.
- Asset Manager로 로드/언로드 할 수 있다.
- Data Asset
- 실제 데이터와 Tag 데이터를 가진다.
- Primary Data Asset에 번들로 포함되어 Asset Manager로 로드/언로드 할 수 있다.
Project Settings 창 > Game > Asset Manager > Primary Asset Types to Scan에서 추가한다.
주요 함수
물리
FTransform RelativeTransform(RotationRotator, LocationVector, ScaleVector);
SubObj->SetRelativeTransform(RelativeTransform);
SubObj->SetRelativeLocation(LocationVector);
SubObj->SetRelativeRotation(RotationRotator);
SubObj->SetRelativeScale3D(ScaleVector);
방향 추출
FRotator Rotator = GetControlRotation();
FVector Direction1 = UKismetMathLibrary::GetForwardVector(FRotator(0, Rotator.Yaw, 0));
FVector Direction2 = UKismetMathLibrary::GetRightVector(FRotator(0, Rotator.Yaw, 0));
Pawn 위치 변경
GetPawn()->AddMovementInput(DirectionVector, ScaleFloat);
- Pawn에 FloatingPawnMovement 컴포넌트가 필요하다.
- ScaleFloat은 1이상일 때만 정규화된다.
PlayerContoroller 방향 변경
AddPitchInput(Val);
AddYawInput(Val);
AddRollInput(Val);
기타
GamePlayTag 설정
#include "NativeGameplayTags.h"
namespace GameplayTagsNamespace
{
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Tag1_Tag2_Tag3);
}
namespace GameplayTagsNamespace
{
UE_DEFINE_GAMEPLAY_TAG(Tag1_Tag2_Tag3, "Tag1.Tag2.Tag3");
}