I’m using the delegate OnMontageEnded of the UAnimInstance
to detect when an attack montage has been completed as such:
void AMyCharacter::Attack(const FInputActionValue &Value) {
if(IsAttacking)
return;
IsAttacking = true;
UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
if(AnimInstance){
AnimInstance->Montage_Play(AttackMontage);
AnimInstance->OnMontageEnded.AddDynamic(this, &AMyCharacter::AttackEnd);
}
}
void AMyCharacter::AttackEnd(UAnimMontage* Montage, bool Interrupted){
UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance();
AnimInstance->OnMontageEnded.RemoveDynamic(this, &AMyCharacter::AttackEnd);
IsAttacking = false;
}
I’ve noticed most tutorials online use notifies for this instead, Can I run into any problems doing it this way?