[UE] AnimInstance를 C++로 제어하기

네,가능합니다 ㅣ 2025. 4. 29. 09:58

 

 

NativeUpdateAnimation을 재정의 하여 Speed와 Direction, 점프상태를 체크할것

 

다음과 같이 내적을 이용하여 정면과 옆면의 벡터길이를 구하고 

 

#include "TPSPlayerAnim.h"

#include "GameFramework/PawnMovementComponent.h"

void UTPSPlayerAnim::NativeUpdateAnimation(float DeltaSeconds)
{
	Super::NativeUpdateAnimation(DeltaSeconds);

	
	if (!Owner->IsValidLowLevel())
	{
		Owner = TryGetPawnOwner();
	}
	else
	{
		FVector v = Owner->GetVelocity();
		Speed = FVector::DotProduct(v, Owner->GetActorForwardVector());

		Direction = FVector::DotProduct(v, Owner->GetActorRightVector());

		bIsInAir = Owner->GetMovementComponent()->IsFalling();
	}
}

 

양수와 음수를 기준으로 트랜지션을 설정해주었음