A follow up to this question
I’m trying to detect the end of a montage section via binding with OnMontageEnded
but it doesn’t work properly as mentioned in the previous question
I tried adding a custom AnimNotify to the end of montage section based on this solution as such:
UDELEGATE()
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnTrigger);
UCLASS()
class MYPROJECT_API UMyAnimNotify : public UAnimNotify {
GENERATED_BODY()
public:
FOnTrigger OnTrigger;
protected:
virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override {
Super::Notify(MeshComp, Animation, EventReference);
OnTrigger.Broadcast();
}
};
AMyCharacter* AMyCharacter::AddCustomNotify(UAnimMontage* Montage, FName Section, float SectionEndTime) {
UMyAnimNotify* MyAnimNotify = NewObject<UMyAnimNotify>(Montage);
FAnimNotifyEvent NewEvent = FAnimNotifyEvent();
NewEvent.NotifyName = FName("MontageSectionEnd");
NewEvent.Notify = MyAnimNotify;
NewEvent.Link(Montage, SectionEndTime);
Montage->Notifies.Add(NewEvent);
Montage->MarkPackageDirty();
MyAnimNotify->OnTrigger.AddDynamic(this, AMyCharacter::MontageFinished);
}
And it works fine and adds the AnimNotify in the montage as such:
However when I restart the editor the My Custom AnimNotifies are gone and no longer visible in the montage timeline
How do I fix this and keep them in montage?