I have a problem. Animation plays but it doesn't see a Notify.

i wanna do, that Player, when he use reload, can’t shoot or does another reload, but animation doesn’t see a Notify, Kinda animation plays, but player can shoot(i use bool variable IsClipingInProgress just to make Player can’t shoot)

this is code, where Notify is used:

Notify:

h

#pragma once

#include "CoreMinimal.h"
#include "Animation/AnimNotifies/AnimNotify.h"
#include "ClipingAnimNotify.generated.h"

DECLARE_MULTICAST_DELEGATE_OneParam(FOnNotifiedSignature, USkeletalMeshComponent*)

UCLASS()
class MYPROJECT_API UClipingAnimNotify : public UAnimNotify
{
    GENERATED_BODY()

public:
    virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation)override;

     FOnNotifiedSignature OnNotified;

 };

cpp

 #include "Animations/ClipingAnimNotify.h" 

void UClipingAnimNotify::Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase*    Animation)
{
    OnNotified.Broadcast(MeshComp);
    Super::Notify(MeshComp, Animation);
}

WeaponComponent:

h

UPROPERTY(EditDefaultsOnly, Category = "Weapon")
	    UAnimMontage* CurrentReloadAnimation = nullptr;

cpp

 void UWeaponComponent::InitAnim()
{
    if (!CurrentReloadAnimation) return;

    const auto& NotifyEvents = CurrentReloadAnimation->Notifies;
    for (const FAnimNotifyEvent& NotifyEvent : NotifyEvents)
    {
	    if (auto ClipingFinishNotify = Cast<UClipingAnimNotify>(NotifyEvent.Notify))
	    {
		            ClipingFinishNotify->OnNotified.AddUObject(this,&UWeaponComponent::OnClipingFinished);
		    break;
	    }
    }
}

void UWeaponComponent::OnClipingFinished(USkeletalMeshComponent* MeshComp)
{
    ACharacter* Character = Cast<ACharacter>(GetOwner());
    if (!Character || MeshComp != Character->GetMesh()) return;
    IsClipingInProgress = false;
}

(I know, that i have many mistakes in my speech. I work)

Easiest way to debug this is to attach Visual Studio’s debugger to the Unreal Editor process and set breakpoints in your code. Then you can see exactly which parts of the code are executed and what the values of your properties are.

Assuming that this part is reached:

ClipingFinishNotify->OnNotified.AddUObject(this,&UWeaponComponent::OnClipingFinished);

Is OnClipingFinished a UFUNCTION() ? It’s required for the binding.

Else, if the notify itself is not reached on the animation, could it be the event is placed at the start of at the end of the animation? Try moving the event inwards a bit I’ve heard the animation could skip over the event.

Hehe, now i have another problem. After changing OnClipingFinished in UFUNCTON() showed this message

D:/UE_4.27/Engine/Plugins/Runtime/ArchVisCharacter/Source/ArchVisCharacter/Public/ArchVisCharMovementComponent.h(1) : Error: UnrealHeaderTool was unable to load source file ‘D:/UE_4.27/Engine/Plugins/Runtime/ArchVisCharacter/Source/ArchVisCharacter/Public/ArchVisCharMovementComponent.h’

Can you post the entire header, no parts deleted?

Also this is a plugin file which you should not modify:

If it’s modified and broken you should validate the engine files / plugin files and revert any made modifications to original.

I used breakpoint and understood, that my game doesn’t use this string. what am i may now?

Is this solved? Does the code compile?

I don’t understand, is ClipingFinishNotify->OnNotified being broadcast or not?

Yep, I solved the problem with unreal error/

About broadcast.

I put a breakpointon this string and checked Reloading. Program didn’t stop and i think, that ClipingFinishNotify->OnNotified wasn’t broadcast

If a breakpoint on this is hit:

ClipingFinishNotify->OnNotified.AddUObject(this,&UWeaponComponent::OnClipingFinished);

and a breakpoint within this method is NOT hit:
OnClipingFinished

Then it is not being broadcast. If it is not being broadcast we need to take a look at the animation, if the animation actually reaches the notification. Could you post a screenshot of that animation line + notification too?

Yep, I have skrin of AM

As far as I can see, with the UFUNCTION added everything else looks fine too.
Only thing I can think of is that maybe the animation blending is causing the notify not to trigger as said here:

Reddit - Dive into anything

Try recreating the notify at frame 40 (outside the blend margin)?