# Adding Custom AnimNotify in montage

**URL:** <https://forums.unrealengine.com/t/adding-custom-animnotify-in-montage/2312057>\
**Category:** C++\
**Tags:** unreal-engine, CPP, question\
**Created:** [January 31, 2025, 5:01pm UTC](https://forums.unrealengine.com/t/adding-custom-animnotify-in-montage/2312057 "2025-01-31T17:01:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrm\_dev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mrm\_dev](https://forums.unrealengine.com/u/mrm_dev)\
**Post date:** [January 31, 2025, 5:01pm UTC](https://forums.unrealengine.com/t/adding-custom-animnotify-in-montage/2312057/1 "2025-01-31T17:01:04Z")

</div>

A follow up to [this](https://forums.unrealengine.com/t/unable-to-play-the-same-montage-twice/2308631) question

I’m trying to detect the end of a montage section via binding with [`OnMontageEnded`](https://dev.epicgames.com/documentation/en-us/unreal-engine/API/Runtime/Engine/Animation/UAnimInstance) but it doesn’t work properly as mentioned in the previous question

I tried adding a custom AnimNotify to the end of montage section based on [this solution](https://forums.unrealengine.com/t/create-animnotify-in-c/301214) as such:

```cpp
UDELEGATE()
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnTrigger);

UCLASS()
class MYPROJECT_API UMyAnimNotify : public UAnimNotify {
    GENERATED_BODY()

   public:
    FOnTrigger OnTrigger;

   protected:
    virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override {
        Super::Notify(MeshComp, Animation, EventReference);

        OnTrigger.Broadcast();
    }
};

```

```cpp

AMyCharacter* AMyCharacter::AddCustomNotify(UAnimMontage* Montage, FName Section, float SectionEndTime) {

    UMyAnimNotify* MyAnimNotify = NewObject<UMyAnimNotify>(Montage);
    FAnimNotifyEvent NewEvent = FAnimNotifyEvent();
    NewEvent.NotifyName = FName("MontageSectionEnd");
    NewEvent.Notify = MyAnimNotify;
    NewEvent.Link(Montage, SectionEndTime);

    Montage->Notifies.Add(NewEvent);
    Montage->MarkPackageDirty();

    MyAnimNotify->OnTrigger.AddDynamic(this, AMyCharacter::MontageFinished);
}

```

And it works fine and adds the AnimNotify in the montage as such:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/a/0/4a018080b3c3eb4516550c417fa5ad850afca393.png)

However when I restart the editor the My Custom AnimNotifies are gone and no longer visible in the montage timeline

How do I fix this and keep them in montage?

---

<div class="post-metadata">

**Author:** ![BRGDemianLopez](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/brgdemianlopez/32/1052421_2.png) [@BRGDemianLopez](https://forums.unrealengine.com/u/BRGDemianLopez)\
**Post date:** [February 18, 2025, 5:10pm UTC](https://forums.unrealengine.com/t/adding-custom-animnotify-in-montage/2312057/2 "2025-02-18T17:10:38Z")

</div>

Hey @mrm_dev hello, can you show me in which part are you calling “AddCustomNotify?”
