Blueprint 애니메이션 생성
서있다가 달려가는 애니메이션을 만들어보자.
- idle을 넣고
- run을 넣는다.
캐릭에 적용해보자.
애니메이션 블루프린트 생성
일단 이렇게 만들기도 가능하다고 알고만 있고 실제는 C++로 제작예정
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Animation/AnimInstance.h"
#include "MainAnimInstance.generated.h"
/**
*
*/
UCLASS()
class BASIC_API UMainAnimInstance : public UAnimInstance
{
GENERATED_BODY()
public:
virtual void NativeInitializeAnimation() override;
UFUNCTION(BlueprintCallable, Category = AnmiationProperties)
void UpdateAnimationProperties();
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Movement)
float MovementSpeed;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Movement)
bool bIsInAir;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Movement)
class APawn* Pawn;
};
#include "MainAnimInstance.h"
#include <Engine/Classes/GameFramework/CharacterMovementComponent.h>
void UMainAnimInstance::NativeInitializeAnimation()
{
if (Pawn == nullptr)
{
Pawn = TryGetPawnOwner();
}
}
void UMainAnimInstance::UpdateAnimationProperties()
{
if (Pawn == nullptr)
{
Pawn = TryGetPawnOwner();
}
if (Pawn)
{
FVector Speed = Pawn->GetVelocity();
FVector LateralSpeed = FVector(Speed.X, Speed.Y, 0.f);
MovementSpeed = LateralSpeed.Size();
bIsInAir = Pawn->GetMovementComponent()->IsFalling();
}
}