Can I add animation notify using only C++?

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);
}
2 Likes