Animation Notify
- 애니메이션 재생 중 특정 시점에 이벤트를 발생시키기 위해 사용하는 기능으로 애니메이션의 특정 프레임에서 소리 재생, 이펙트 트리거, 게임 로직 호출 등의 작업을 수행할 수 있다.
Animation Notify 만들기
public:
UMyAnimNotify_SendGameplayEvent(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
protected:
virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override;
protected:
UPROPERTY(EditAnywhere)
FGameplayTag EventTag;
void UMyAnimNotify_SendGameplayEvent::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference)
{
Super::Notify(MeshComp, Animation, EventReference);
AMyCharacter* LocalCharacter = Cast<AMyCharacter>(MeshComp->GetOwner());
if (LocalCharacter)
{
LocalCharacter->HandleGameplayEvent(EventTag);
}
}
- 생성자와 Notify를 받아주는 함수를 오버라이딩 해서 사용
- Notify가 발생하면 해당 함수로 들어온다
- 이벤트마다 Notify를 만들면 비효율적이기 때문에 이벤트의 종류를 GameplayTag로 전달한다
Animation Notify 추가

- 우클릭을 통해 기존에 만들어져있는 Notify를 추가할수도 있고 새로 만들수도 있다.

GameplayTag 추가
namespace MyGameplayTags
{
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Input_Action_SetDestination);
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Event_Montage_Begin);
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Event_Montage_End);
UE_DECLARE_GAMEPLAY_TAG_EXTERN(Event_Montage_Attack);
}
Notify에 GameplayTag를 설정할 수 있다

- 해당 이벤트를 Notify 함수에 전달해서 처리하도록 함
캐릭터에서 이벤트를 처리하도록 만들기
public:
virtual void HandleGameplayEvent(FGameplayTag EventTag);
void AMyCharacter::HandleGameplayEvent(FGameplayTag EventTag)
{
}
플레이어에서 상속받아 컨트롤러에서 처리하도록
public:
virtual void HandleGameplayEvent(FGameplayTag EventTag) override;
void AMyPlayer::HandleGameplayEvent(FGameplayTag EventTag)
{
AMyPlayerController* PC = Cast<AMyPlayerController>(GetController());
if (PC)
{
PC->HandleGameplayEvent(EventTag);
}
}
void AMyPlayerController::HandleGameplayEvent(FGameplayTag EventTag)
{
if (EventTag.MatchesTag(MyGameplayTags::Event_Montage_Attack))
{
if (TargetActor)
{
TargetActor->OnDamaged(MyPlayer->FinalDamage, MyPlayer);
}
}
}
- 임시로 컨트롤러에서 이벤트를 처리하도록 한다
- MatchesTag를 이용해서 태그를 비교할 수 있다