Hey,
Given a SkeletelMeshComponent, a time and an animation I’d like to create a notify, add that notify to the animation and add my function as a callback to the notify event.
I’ve found some code on the AnswerHub but I don’t quite understand it. I assume it creates a notify and adds it to the montage.
void MyComponent::AddNotify(UAnimMontage * montage_in, FString notify_name_in, int32 frame_in)
{
if (notify_name_in.IsEmpty())
return;
int32 my_index = montage_in->Notifies.Add(FAnimNotifyEvent());
FAnimNotifyEvent& new_event = montage_in->Notifies[my_index];
new_event.NotifyName = FName("Fire");
new_event.Link(montage_in, frame_in* (1.0f / 30.0f));
class UObject* AnimNotifyClass = NewObject<UObject>(montage_in, UAnimNotifyState::StaticClass(), NAME_None, RF_Transactional);
new_event.NotifyStateClass = Cast<UAnimNotifyState>(AnimNotifyClass);
if (new_event.NotifyStateClass)
{
new_event.NotifyName = FName(*new_event.NotifyStateClass->GetNotifyName());
new_event.SetDuration(1 / 30.f);
new_event.EndLink.Link(montage_in, new_event.EndLink.GetTime());
}
else
{
new_event.NotifyName = FName(*new_event.Notify->GetNotifyName());
}
montage_in->MarkPackageDirty();
}
If that’s the proper way of creating & adding notifys I’d like to know how to add my function as callback to the created notify. Sadly I couldn’t find documentation for this.
How do you handle notifys in C++? Should I dig into the Engine Code to understand it?