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)