Animation Montage 심화
Montage Section, Branch Point, Slot Node의 내부 동작과 고급 콤보 시스템 구현을 분석합니다.
Montage 아키텍처
UAnimMontage의 내부 구조와 재생 메커니즘
UAnimMontage는 애니메이션 시퀀스 위에 구축된 고수준 애셋으로, 섹션 분할, 분기 재생, 블렌딩 제어, Notify 타이밍 등을 정밀하게 관리합니다. 공격, 스킬, 인터랙션 같은 게임플레이 주도 애니메이션에 사용됩니다.
// Montage 재생 (C++)
void AMyCharacter::PlayAttackMontage()
{
UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
if (!AnimInstance) return;
// 기본 재생
float Duration = AnimInstance->Montage_Play(AttackMontage, 1.0f);
// 특정 섹션부터 재생
AnimInstance->Montage_JumpToSection(FName("Loop"), AttackMontage);
// 재생 완료 델리게이트
FOnMontageEnded EndDelegate;
EndDelegate.BindUObject(this, &AMyCharacter::OnAttackMontageEnded);
AnimInstance->Montage_SetEndDelegate(EndDelegate, AttackMontage);
}
Section과 Branch Point
섹션 분할로 Montage 흐름을 동적으로 제어하는 기법
Section은 Montage를 논리적 구간으로 분할합니다. 각 섹션은 다음 섹션 링크를 가지며, 런타임에 Montage_JumpToSection이나 Montage_SetNextSection으로 재생 흐름을 변경할 수 있습니다.
| Branch Point 타입 | 실행 방식 | 정밀도 | 사용 사례 |
|---|---|---|---|
| Queued | 다음 틱에서 실행 | 프레임 단위 | 파티클, 사운드 |
| Tick (Branching Point) | 즉시 실행 | 서브프레임 | 콤보 입력 분기, 히트 판정 |
// 콤보 시스템 구현 예시
void AMyCharacter::OnComboWindowOpen()
{
bCanCombo = true;
}
void AMyCharacter::OnComboWindowClose()
{
if (bCanCombo && bComboInputReceived)
{
// 다음 콤보 섹션으로 이동
UAnimInstance* AnimInst = GetMesh()->GetAnimInstance();
AnimInst->Montage_SetNextSection(
CurrentComboSection, // "Attack1_End"
NextComboSection, // "Attack2_Start"
AttackMontage
);
}
bCanCombo = false;
bComboInputReceived = false;
}
Slot Node와 블렌딩
AnimGraph의 Slot Node를 통한 Montage 삽입과 블렌딩 제어
Montage는 AnimGraph의 Slot Node를 통해 기존 애니메이션 파이프라인에 삽입됩니다. Montage의 SlotName과 Slot Node의 이름이 일치하면, 해당 Slot에서 Montage 포즈가 기존 포즈를 대체하거나 블렌딩됩니다.
BlendIn
Montage 시작 시 기존 포즈에서 Montage 포즈로의 블렌딩. 시간, 커브, 블렌드 모드를 설정합니다.
BlendOut
Montage 종료 시 다시 기존 포즈로 복귀하는 블렌딩. BlendOut Trigger Time으로 미리 시작할 수 있습니다.
Slot Group
같은 Slot Group의 Slot들은 한 번에 하나의 Montage만 재생합니다. 다른 Group의 Slot은 독립 재생 가능합니다.
Per Bone Blend
Slot Node에서 Per Bone Layer 설정으로 특정 본에만 Montage를 적용할 수 있습니다.
Montage의 BlendIn/BlendOut에서도 Inertialization을 사용할 수 있습니다. Blend Mode를 "Inertialization"으로 설정하면, 기존 포즈의 관성을 유지하면서 Montage 포즈로 전환되어 더 자연스러운 진입/퇴장이 가능합니다. 특히 빠른 BlendIn이 필요한 공격 Montage에 효과적입니다.
Montage 고급 패턴
Root Motion, 다중 Slot, 네트워크 동기화 패턴
// Root Motion Montage 활용
void AMyCharacter::PlayDashMontage()
{
UAnimInstance* AnimInst = GetMesh()->GetAnimInstance();
// Root Motion 활성화 확인
// Montage의 Enable Root Motion = true 필요
float Duration = AnimInst->Montage_Play(DashMontage, 1.5f);
// Root Motion 중 이동 제어
// CharacterMovement->RootMotionParams에서 자동 적용
}
// Montage 이벤트 콜백
void AMyCharacter::OnMontageBlendingOut(
UAnimMontage* Montage, bool bInterrupted)
{
if (bInterrupted)
{
// 다른 Montage나 Stop에 의해 중단됨
HandleMontageInterrupted(Montage);
}
else
{
// 정상 종료 (BlendOut 시작)
HandleMontageCompleting(Montage);
}
}
// GAS (Gameplay Ability System) 연동
// AbilityTask_PlayMontageAndWait 사용
// Montage 완료/중단/취소를 Ability에서 감지
멀티플레이어에서 Montage는 PlayMontage RPC로 서버에서 클라이언트로 전파됩니다. 서버 권위 모델에서는 서버에서만 Montage_Play를 호출하고, 클라이언트는 AnimInstance의 자동 리플리케이션으로 동기화합니다. GetCurrentMontage()로 현재 재생 상태를 확인할 수 있습니다.
핵심 요약
- UAnimMontage는 Section, Notify, BlendIn/Out 등을 관리하는 고수준 애니메이션 애셋이다.
- Section으로 Montage를 분할하고,
Montage_SetNextSection으로 런타임 흐름을 제어한다. - Branch Point(Tick)는 서브프레임 정밀도로 즉시 실행되어 콤보 분기 등에 사용된다.
- Slot Node가 AnimGraph에서 Montage를 기존 포즈에 삽입하며, Inertialization으로 자연스러운 블렌딩을 달성한다.
- 멀티플레이어에서는 서버 권위 모델로 Montage를 관리하고 자동 리플리케이션으로 동기화한다.
도전 과제
배운 내용을 직접 실습해보세요
공격 애니메이션으로 Animation Montage를 생성하고, Default Slot에 배치하세요. AnimBP의 AnimGraph에 Slot 노드(DefaultSlot)를 추가하고, 블루프린트에서 Play Montage 노드로 입력 시 재생하세요. On Completed, On Interrupted 콜백도 연결하세요.
Montage에 Attack1, Attack2, Attack3 세 개의 Section을 생성하세요. 기본적으로 Attack1에서 멈추고, 타이밍 내 입력이 들어오면 Montage Set Next Section으로 Attack2 → Attack3로 연결되는 3단 콤보 시스템을 구현하세요.
C++에서 PlayMontage를 호출하고, FOnMontageEnded 델리게이트로 종료를 감지하는 코드를 작성하세요. 여러 Montage Slot(UpperBody, FullBody)을 사용하여 이동 중 상체만 공격 모션을 재생하고, Montage Blend Out으로 자연스러운 복귀를 구현하세요.