# Can I add animation notify using only C++?

**URL:** <https://forums.unrealengine.com/t/can-i-add-animation-notify-using-only-c/414855>\
**Category:** Character & Animation\
**Tags:** notify, unreal-engine, UE4, question, CPP\
**Created:** [January 18, 2018, 3:31am UTC](https://forums.unrealengine.com/t/can-i-add-animation-notify-using-only-c/414855 "2018-01-18T03:31:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kkljh1212](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kkljh1212](https://forums.unrealengine.com/u/kkljh1212)\
**Post date:** [January 18, 2018, 3:31am UTC](https://forums.unrealengine.com/t/can-i-add-animation-notify-using-only-c/414855/1 "2018-01-18T03:31:00Z")

</div>

Hello. Unreal Developer !  
I can not speak English very well. hope you understand.

My question is,  
**Can I use C ++ only to add “Notify” to the montage and receive events from this “Notify”?**

If this is possible,  
Could you explain how to implement it?

  
https://answers.unrealengine.com/questions/440602/custom-animnotify-in-c-uanimsequencebase-is-null.html https://answers.unrealengine.com/questions/231681/my-uanimnotify-custom-c-class-received-notify-wont.html https://answers.unrealengine.com/questions/441017/how-to-get-character-within-uanimnotify.html https://forums.unrealengine.com/development-discussion/c-gameplay-programming/45844-is-it-possible-to-run-c-code-from-an-animation-notify?74606-Is-it-possible-to-run-C-code-from-an-animation-Notify=  
This is what I found when I did a search, and I think it seems to be possible to implement it.

**I want to implement,**   
  
**I want to add “Notify” before playing montage and receive an event for “Notify” I added while montage is playing.**   
  
**i need to add “notify” dynamically depending on the data in the CSV file( or ini file ).**  
  
  
  
To implement this,  
Create a new class derived from UAnimNotify or UAnimNotifyState,  
Also,  
Should I also create a new class derived from UAnimInstance?

  
 **If you know about this, please feel free to reply.** thank you.

---

<div class="post-metadata">

**Author:** ![kkljh1212](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kkljh1212](https://forums.unrealengine.com/u/kkljh1212)\
**Post date:** [January 25, 2018, 1:52am UTC](https://forums.unrealengine.com/t/can-i-add-animation-notify-using-only-c/414855/2 "2018-01-25T01:52:34Z")

</div>

I solved this problem.

  

```
void TEST::add_notify_in_montage(UAnimMontage* montage_in, FString notify_name_in, int32 frame_in)
{
	if (notify_name_in.IsEmpty())
		return;

	class UObject* AnimNotifyClass = NewObject<UObject>(montage_in, UCustomAnimNotify::StaticClass(), NAME_None, RF_Transactional);
	int32 my_index = montage_in->Notifies.Add(FAnimNotifyEvent());
	FAnimNotifyEvent& new_event = montage_in->Notifies[my_index];

	// Here you set the necessary information for the Custom Class.
	// I need "Notify" index and the name I defined.
	UCustomAnimNotify* notify = Cast<UCustomAnimNotify>(AnimNotifyClass);
	notify->set_notify_name(notify_name_in);
	notify->set_notify_index(my_index);
	
	new_event.Notify = Cast<UAnimNotify>(notify);
	new_event.Link(montage_in, (float)frame_in / ANIMATION_FPS);
}

```

---

<div class="post-metadata">

**Author:** ![kkljh1212](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kkljh1212](https://forums.unrealengine.com/u/kkljh1212)\
**Post date:** [January 25, 2018, 1:58am UTC](https://forums.unrealengine.com/t/can-i-add-animation-notify-using-only-c/414855/3 "2018-01-25T01:58:44Z")

</div>

You can also implement “NotifyState” in this way.  
I created “UCustomNotify” using “UAnimNotify”.  
You can implement “NofiyState” any number of times by using “UAnimNofifyState”.

---

<div class="post-metadata">

**Author:** ![Skino88](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Skino88](https://forums.unrealengine.com/u/Skino88)\
**Post date:** [June 22, 2025, 10:32am UTC](https://forums.unrealengine.com/t/can-i-add-animation-notify-using-only-c/414855/4 "2025-06-22T10:32:37Z")

</div>

```auto
void UGHNPCAnimation::AddEventsToAnimMontage(UAnimMontage* AnimMontage, UAnimationData* AnimationData)
{
	for (auto& EventData : AnimationData->Events)
	{
		auto AnimNotify = NewObject<UGHAnimNotify>(AnimMontage, UGHAnimNotify::StaticClass(),
			NAME_None, RF_Transactional);
		AnimNotify->EventData = &EventData;
	
		auto NotifyEvent = FAnimNotifyEvent();
		NotifyEvent.Notify = AnimNotify;
		NotifyEvent.Link(AnimMontage, EventData.Time > 0 ? EventData.Time : 0.01f);
	
		AnimMontage->Notifies.Add(NotifyEvent);
	}
}

```
