keywords: [UE4]Animation Notifications (AnimNotify)

keyword: AnimNotify、Animation Notify、动画的事件通知

Add Custom Parameters in AnimNotify

Steps:

  1. Add Custom C++ AnimNotify Class

     UCLASS()
     class TOWERDEFENSE_API UAnimNotify_Test : public UAnimNotify
     {
         GENERATED_BODY()
    
     protected:
    
         virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) override;
    
     protected:
    
         UPROPERTY(EditAnywhere)
             FString Param;
    
     };
    
     void UAnimNotify_Test::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation)
     {
         Super::Notify(MeshComp, Animation);
    
         if (Param == TEXT("AAA"))
         {
             if(AActor* Actor = MeshComp->GetOwner())
             {
                 AMyCharacter* Character = Cast<AMyCharacter>(Actor);
                 ...
             }
         }
     }
    
  2. Add AnimNotify in Animation asset

  3. Edit Custom Parameters

Note: Add custom parameters in AnimNotifyState is same as AnimNotify.

Remove Custom AnimNotify
Difference Between AnimNotify and AnimNotifyState

AnimNotifyState can set notify time range, and it contains callback function NotifyBegin, NotifyTick, NotifyEnd;
AnimNotify can only be triggered at the moment, only has callback function Notify.

References

Animation Notifications (Notifies)
https://docs.unrealengine.com/latest/INT/Engine/Animation/Sequences/Notifies/

ue4中动画通知的两种方式(蓝图和C++)
http://blog.csdn.net/yangxuan0261/article/details/52097917

Reference: Rename or delete anim notifys?
https://answers.unrealengine.com/questions/465629/rename-or-delete-anim-notifys.html