Custom AnimNotify in C++, UAnimSequenceBase is NULL

anonymous_user_6d19da77
Thu, 23 Jun 2016 04:11:20 +0000
Character & Animation

I’m implementing custom AnimNotify behavior at runtime, and linking the notify with an AnimMontage created using PlaySlotAnimationAsDynamicMontage(). I’m able to create a new FAnimNotifyEvent and set the Notify class to my custom AnimNotify. The callback is firing, but its UAnimSequenceBase* Animation parameter is always NULL.

Is this due to an issue with referencing a dynamic Montage from PlaySlotAnimationAsDynamicMontage() ? My code is very similar to link:(Create AnimNotify in c++ - Character & Animation - Epic Developer Community Forums)

UAnimMontage *montage = animInstHead->PlaySlotAnimationAsDynamicMontage(animSeq, bodySlotName, 0.25f, 0.f, 1.0f, 1, 0.f);
montage->Notifies.Empty();
int32 notifyIndex = montage->Notifies.Add(FAnimNotifyEvent());
FAnimNotifyEvent& notifyEvent = montage->Notifies[notifyIndex];
notifyEvent.NotifyName = FName("Ending");
class UObject* NotifyClass = ConstructObject<UObject>(UCustomAnimNotify::StaticClass());
notifyEvent.Notify = Cast<UAnimNotify>(NotifyClass);
notifyEvent.LinkMontage(montage, 2.f);

Here is the Notify callback:

void UCustomAnimNotify::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation)
{
	// MeshComp is valid
	// Animation is always NULL
}

I also tried using custom AnimNotifyState as shown in the link above, but I couldn’t get this to work at all - it wouldn’t fire the NotifyBegin callback.

I wonder if this is caused by referencing a Montage created by PlaySlotAnimationAsDynamicMontage. Has anyone else seen this issue?

2 posts - 1 participant