How can I bind a function to AnimInstance->OnMontageEnd?

Hi All,

I have a mesh, and would like to bind a function in my class to its AnimInstance’s OnMontageEnded delegate.

e.g.

Arm->GetAnimInstance()->OnMontageEnded.Add(something)

For the life of me I cannot figure out what the “something” should be.

// Function declaration in header
void OnAnimationEnded(UAnimMontage* Montage, bool bInterrupted);

// In implementation
// Declare delegate
FOnMontageEnded EndDelegate;
 // Bind it
EndDelegate.BindUObject(this, &UMyClass::OnAnimationEnded);
//Set it
MyAnimInstance->Montage_SetEndDelegate(EndDelegate);
3 Likes

Thanks very much for the reply dzeligman, I will try it out over the weekend and post back with results.

Awesome! Works like a charm. Thanks!

It really work!, thank you!

Fantastic! Remember to Set the EndDelegate after you play the Animation Montage! Caused me a bit of headache trying to find out what was wrong with my code, but I figured it out eventually. This post was a life-saver!

3 Likes