콘텐츠로 이동

UE5 절차적 애니메이션 (IK, 절차적 본 제어)

키프레임 애니메이션 클립 없이 수학적 계산으로 본을 실시간 제어하는 기법입니다. 지형에 따른 발 접지, 조준 방향 머리 회전, 물리 기반 흔들림 등에 사용됩니다.

UE5 Animation Blueprint에서 FBIK 노드를 추가합니다.

AnimGraph:
Sequence Player
Full Body IK
├─ Effectors: LeftFoot, RightFoot, LeftHand, RightHand
└─ Settings: Solver Iterations: 30

C++에서 Effector 위치를 매 프레임 갱신합니다.

// AnimInstance에서 IK 타겟 위치 계산
void UMyAnimInstance::NativeUpdateAnimation(float DeltaSeconds) {
Super::NativeUpdateAnimation(DeltaSeconds);
AMyCharacter* Char = Cast<AMyCharacter>(TryGetPawnOwner());
if (!Char) return;
// 발 접지 IK 계산
LeftFootIKTarget = CalculateFootTarget(Char, true);
RightFootIKTarget = CalculateFootTarget(Char, false);
}
FVector UMyAnimInstance::CalculateFootTarget(AMyCharacter* Char, bool bLeft) {
FName Socket = bLeft ? "LeftFoot" : "RightFoot";
FVector FootLoc = Char->GetMesh()->GetSocketLocation(Socket);
FHitResult Hit;
FVector Start = FootLoc + FVector(0, 0, 50);
FVector End = FootLoc - FVector(0, 0, 100);
if (GetWorld()->LineTraceSingleByChannel(Hit, Start, End, ECC_Visibility)) {
// 지형 높이에 발 위치 맞추기
return FMath::VInterpTo(FootLoc, Hit.Location, DeltaSeconds, 15.f);
}
return FootLoc;
}
AnimGraph:
Sequence Player
Two Bone IK
├─ IKBone: foot_r
├─ Effector Location (World Space): RightFootIKTarget
├─ Join Target Location: 무릎 힌트 위치
└─ Allow Stretching: false
// AnimInstance 프로퍼티
UPROPERTY(BlueprintReadWrite)
FVector RightFootIKTarget;
UPROPERTY(BlueprintReadWrite)
float RightFootAlpha = 1.0f; // IK 블렌딩 강도 (0 = 오프, 1 = 풀)
Control Rig:
Spine Solve:
Get Spine Bones (pelvis → spine_03)
Apply Forward/Backward Tilt (입력값에 따라)
Apply Left/Right Lean (이동 방향에 따라)
// AnimInstance에서 Rig에 값 전달
void UMyAnimInstance::NativeUpdateAnimation(float DeltaSeconds) {
// 속도에 따른 전후 기울기
FVector Velocity = Pawn->GetVelocity();
float ForwardSpeed = FVector::DotProduct(Velocity, Pawn->GetActorForwardVector());
SpineTilt = FMath::FInterpTo(SpineTilt, ForwardSpeed * 0.02f, DeltaSeconds, 8.f);
}
// Spring Arm 방식의 절차적 흔들림
struct FSpringBone {
FVector Position;
FVector Velocity;
FVector Update(FVector Target, float DeltaTime, float Stiffness, float Damping) {
FVector Force = (Target - Position) * Stiffness - Velocity * Damping;
Velocity += Force * DeltaTime;
Position += Velocity * DeltaTime;
return Position;
}
};
// AnimInstance에서 매 프레임 갱신
void UMyAnimInstance::NativeUpdateAnimation(float DeltaSeconds) {
FVector TailRoot = GetMesh()->GetSocketLocation("tail_root");
TailTipPosition = TailSpring.Update(TailRoot + FVector(0, 0, -30),
DeltaSeconds, 80.f, 6.f);
}
Aim Offset 에셋:
Grid: Horizontal (-90 ~ 90), Vertical (-90 ~ 90)
Poses: 9 방향 포즈 설정
AnimGraph:
Sequence Player (이동 애니)
↓ (Layered Blend by Bone: spine_01 이상)
Aim Offset
├─ Pitch: AimPitch
└─ Yaw: AimYaw - CharacterYaw (상대 각도)
  • FBIK / Two Bone IK로 지형 적응형 발 접지 구현
  • Control Rig으로 스파인 기울기, 조준 회전 등 상체 절차적 제어
  • Spring Bone으로 꼬리/머리카락/장비 물리 흔들림
  • Aim Offset으로 8방향 조준 애니메이션 보간
  • 모든 IK 타겟 값은 AnimInstance::NativeUpdateAnimation에서 계산