본문 바로가기
언리얼 엔진/기초

[Unreal Engine5] C++에서 몽타주(Montage) 플레이하기

by TyT. 2023. 8. 23.
반응형

GitHub: https://github.com/tyt0815

 

tyt0815 - Overview

tyt0815 has 4 repositories available. Follow their code on GitHub.

github.com

Notion: https://www.notion.so/tyt0815/a16514d41cb240f08aa19fe5b4c0ab86?pvs=4 

 

언리얼 엔진

Unreal Engine 5 C++ The Ultimate Game Developer Course

www.notion.so

※노션에 기존에 작성하던 글이 있으니 참고

Play Montage

먼저 플레이할 몽타주를 변수로 선언해 줍니다.

UPROPERTY(EditAnywhere, Category = Montage)
UAnimMontage* MyMontage;

그리고 몽타주를 플레이하는 함수를 정의해 줍니다.

void ABaseCharacter::PlayMontageSection(UAnimMontage* Montage, FName SectionName)
{
	UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
	if (AnimInstance && Montage)
	{
		AnimInstance->Montage_Play(Montage);
		AnimInstance->Montage_JumpToSection(SectionName, Montage);
	}
}

 

위 함수에 Montage변수와 SectionName를 파라미터로 주면 사용할 수 있습니다.

PlayMontageSection(MyMontage, "Attack2");

컴파일하고 블루프린트 편집기로 와서 몽타주를 설정해 줍니다.

설정된 몽타주는 아래와 같습니다. 아래에 밑줄친 "Attack2"섹션이 플레이 될 것 입니다.

 

플레이해서 확인해 봅니다.

반응형