# How can I listen for an anim notify event on C++?

**URL:** <https://forums.unrealengine.com/t/how-can-i-listen-for-an-anim-notify-event-on-c/343231>\
**Category:** Character & Animation\
**Tags:** notify, unreal-engine, CPP, Blueprint, question\
**Created:** [January 6, 2016, 12:34am UTC](https://forums.unrealengine.com/t/how-can-i-listen-for-an-anim-notify-event-on-c/343231 "2016-01-06T00:34:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vrtual](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vrtual/32/1025445_2.png) [@Vrtual](https://forums.unrealengine.com/u/Vrtual)\
**Post date:** [January 6, 2016, 12:34am UTC](https://forums.unrealengine.com/t/how-can-i-listen-for-an-anim-notify-event-on-c/343231/1 "2016-01-06T00:34:38Z")

</div>

I have a montage with a custom notify and I have inherited the UAnimInstance to handle my animationBP from code, that being said I have access to the FAnimNotifyEvent but how do I declare a callback on C++? On the BP you just add a new “Anim notify event” and that’s it, how can I do the same on code?

P.D. I don’t want to add anything on my blueprint for this, how do I make the callback only on code side?. I think I could create a subclass of UAnimNotify (or UAnimNotifyState) and override their methods but then the callback implementation lacks the UAnimInstance’s variables I have, so far I can only think about exposing the method I want to call on C++ for my BP to call it whenever the notify fires.

---

<div class="post-metadata">

**Author:** ![rantrod](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rantrod](https://forums.unrealengine.com/u/rantrod)\
**Post date:** [January 6, 2016, 9:51pm UTC](https://forums.unrealengine.com/t/how-can-i-listen-for-an-anim-notify-event-on-c/343231/2 "2016-01-06T21:51:59Z")

</div>

If I understood the question correctly, this could help:

> **[Create AnimNotify in c++](https://forums.unrealengine.com/questions/145350/create-animnotify-in-c.html)**
>
> Hi. I’m trying to create AnimNotifies in code so I can drive notifies from a excel datatable. The code below seems to work, it adds a notify to notify track 0 in my UAnimMontage is visible in the editor and fires events in game. However if I click...

---

<div class="post-metadata">

**Author:** ![Vrtual](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vrtual/32/1025445_2.png) [@Vrtual](https://forums.unrealengine.com/u/Vrtual)\
**Post date:** [January 6, 2016, 10:29pm UTC](https://forums.unrealengine.com/t/how-can-i-listen-for-an-anim-notify-event-on-c/343231/3 "2016-01-06T22:29:08Z")

</div>

I encountered that same question before, he is adding a notify from code but he has an inherited class of UAnimNotifyState where all the events fired by the notify are handled, and as I pointed out I want to be able to create a callback on my UAnimInstance custom class (like you would usually do on a BP), if you know of a way to connect the event from the UAnimNotifyState to the UAnimInstance callback please let me know.

---

<div class="post-metadata">

**Author:** ![rantrod](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rantrod](https://forums.unrealengine.com/u/rantrod)\
**Post date:** [January 6, 2016, 10:54pm UTC](https://forums.unrealengine.com/t/how-can-i-listen-for-an-anim-notify-event-on-c/343231/4 "2016-01-06T22:54:35Z")

</div>

If you derive from AnimNotify, the first argument to the callback (Received\_Notify) is USkeletalMeshComponent. You can get to your anim instance from there.

---

<div class="post-metadata">

**Author:** ![Vrtual](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vrtual/32/1025445_2.png) [@Vrtual](https://forums.unrealengine.com/u/Vrtual)\
**Post date:** [January 7, 2016, 1:16am UTC](https://forums.unrealengine.com/t/how-can-i-listen-for-an-anim-notify-event-on-c/343231/5 "2016-01-07T01:16:13Z")

</div>

Oh really? didn’t notice that, thanks!  
Edit: I just did some refactoring on my code and this totally worked, thanks again for your help 🙂

---

<div class="post-metadata">

**Author:** ![Fulezi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fulezi/32/813318_2.png) [@Fulezi](https://forums.unrealengine.com/u/Fulezi)\
**Post date:** [May 23, 2024, 1:13pm UTC](https://forums.unrealengine.com/t/how-can-i-listen-for-an-anim-notify-event-on-c/343231/6 "2024-05-23T13:13:08Z")

</div>

On my case I was looking for:

```auto
UAnimInstance* AnimInstance = /* ... */;
if (AnimInstance)
{
	AnimInstance->OnPlayMontageNotifyBegin.
	              AddDynamic(this, &UBHAbilityTask_PlayMontageAndWait::NotifyBegin);
	AnimInstance->OnPlayMontageNotifyEnd.AddDynamic(this, &UBHAbilityTask_PlayMontageAndWait::NotifyEnd);
}

void UBHAbilityTask_PlayMontageAndWait::NotifyBegin(FName NotifyName,
                                                    const FBranchingPointNotifyPayload& BranchingPointPayload)
{
	/* ... */
}

void UBHAbilityTask_PlayMontageAndWait::NotifyEnd(FName NotifyName,
                                                  const FBranchingPointNotifyPayload& BranchingPointPayload)
{
	/* ... */
}
```

---

<div class="post-metadata">

**Author:** ![Badipaddress](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Badipaddress](https://forums.unrealengine.com/u/Badipaddress)\
**Post date:** [August 29, 2024, 10:44am UTC](https://forums.unrealengine.com/t/how-can-i-listen-for-an-anim-notify-event-on-c/343231/7 "2024-08-29T10:44:32Z")

</div>

Did you manage to get these callback functions with AnimNotifyState?

---

<div class="post-metadata">

**Author:** ![MostHost\_LA](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mosthost_la/32/907035_2.png) [@MostHost\_LA](https://forums.unrealengine.com/u/MostHost_LA)\
**Post date:** [August 29, 2024, 11:37pm UTC](https://forums.unrealengine.com/t/how-can-i-listen-for-an-anim-notify-event-on-c/343231/8 "2024-08-29T23:37:12Z")

</div>

One of the 2 options gives you no guarantee that the notify would ever fire in the first place.  
(Cant remeber which).

The Notify docs oage should have clarity on that.

Essentially only notifies that are created and set between abimation state machines are going to ever fire 100% of the time.

So, not that implemeting a c++ function for it is completely pointless, _but_ do consider the fact you won’t necessarily ever get a callback to fire…

---

<div class="post-metadata">

**Author:** ![indianapapi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@indianapapi](https://forums.unrealengine.com/u/indianapapi)\
**Post date:** [March 10, 2025, 10:33pm UTC](https://forums.unrealengine.com/t/how-can-i-listen-for-an-anim-notify-event-on-c/343231/9 "2025-03-10T22:33:28Z")

</div>

I recently had this issue, in 5.5, and came across this post. I tried to use AnimInstance-\>OnPlayMontageNotifyBegin.AddDynamic inside of a behavior tree task and the notify never fired.

My solution was to create a custom UAnimInstance C++ class and make this my base class in my Animation Blueprints.

In the .h file I have a private UFUNCTION.

```auto
UFUNCTION()
    void HandleMontageNotifyBegin(FName NotifyName, const FBranchingPointNotifyPayload &BranchingPointPayload);

```

I implement the function in the .cpp file like this. In the NativeInitializeAnimation function I add it using AddUniqueDynamic.

```auto
void UBOJ_Animation_Instance_Base::NativeInitializeAnimation()
{
    Super::NativeInitializeAnimation();

    // Bind our notify function so it triggers whenever a Montage Notify begins
    OnPlayMontageNotifyBegin.AddUniqueDynamic(this, &UBOJ_Animation_Instance_Base::HandleMontageNotifyBegin);
}

```

Lastly I provide the HandleMontageNotifyBegin function that is called.

```auto
void UBOJ_Animation_Instance_Base::HandleMontageNotifyBegin(FName NotifyName, const FBranchingPointNotifyPayload &BranchingPointPayload)
{
    if (NotifyName == TEXT("Damage"))
    {
        UE_LOG(BOJ_AI, Log, TEXT("Damage notify begin fired!"));
    }
}

```

All montages fire all notfy’s within in them every time. Hope this helps someone that comes across this post in the future.
