Here is how I set it up:
void UBPCharacterAnimInstance::NativeInitializeAnimation()
{
OnMontageStarted.AddDynamic(this, &UBPCharacterAnimInstance::SetCorrectWeaponMontage);
}
void UBPCharacterAnimInstance::SetCorrectWeaponMontage(UAnimMontage* AnimMontage)
{
UE_LOG(LogTemp, Warning, TEXT("AnimMontage: %s"), *AnimMontage->GetName());
AShooterCharacter* CurrentCharacter = Cast<AShooterCharacter>(GetOwningActor());
if (CurrentCharacter)
{
ABPWeapon_Additionals* CurrentWeapon = Cast<ABPWeapon_Additionals>(CurrentCharacter->GetWeapon());
if (CurrentWeapon)
{
UE_LOG(LogTemp, Warning, TEXT("CurrentWeapon: %s"), *CurrentWeapon->GetName())
}
}
}
I went through the anim instance code and can see the actual broadcast function being called. Does anyone have any idea what I could be doing wrong or where to look for issues?