애니메이션 파일로 재생하는 방법
void AABPawn::BeginPlay()
{
Super::BeginPlay();
Mesh->SetAnimationMode(EAnimationMode::AnimationSingleNode);
UAnimationAsset* AnimAsset = LoadObject<UAnimationAsset>(nullptr,
TEXT("/Game/Book/ANIM/WarriorRun.WarriorRun"));
if (AnimAsset != nullptr)
{
Mesh->PlayAnimation(AnimAsset, true);
}
}
애니메이션 블루프린트를 이용해서 재생하는 방법 생성자에서 해야함. beginplay에서 할려고 뻥남
AABPawn::AABPawn()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
Capsule = CreateDefaultSubobject<UCapsuleComponent>(TEXT("CAPSULE"));
Mesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("MESH"));
Movement = CreateDefaultSubobject<UFloatingPawnMovement>(TEXT("MOVEMENT"));
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SPRINGARM"));
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("CAMERA"));
RootComponent = Capsule;
Mesh->SetupAttachment(Capsule);
SpringArm->SetupAttachment(Capsule);
Camera->SetupAttachment(SpringArm);
Capsule->SetCapsuleHalfHeight(88.0f);
Capsule->SetCapsuleRadius(34.0f);
Mesh->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())
{
Mesh->SetSkeletalMesh(SK_CARDBOARD.Object);
}
//코드 추가됨
Mesh->SetAnimationMode(EAnimationMode::AnimationBlueprint);
static ConstructorHelpers::FClassFinder<UAnimInstance> WARRIOR_ANIM(TEXT("/Game/Book/ANIM/WarriorAnimBluePrint.WarriorAnimBluePrint_C"));
if (WARRIOR_ANIM.Succeeded())
{
Mesh->SetAnimInstanceClass(WARRIOR_ANIM.Class);
}
}
'Unreal > Game 1 (C++)' 카테고리의 다른 글
6.3인칭 컨트롤 구현 (GTA 방식) (0) | 2019.05.02 |
---|---|
5.캐릭터 생성 (0) | 2019.05.02 |
3.에디터 - 폰 입력 연동, 바인딩 (0) | 2019.05.02 |
2.캐릭터에 들어가는 기본적인 항목 (0) | 2019.05.01 |
1.게임모드, 폰, 컨트롤러 (디폴트) (0) | 2019.05.01 |