How Do I get NotifyName pin in c++? Need to check condition if Notify Name == "Pull".

here i found variable FName NotifyName;
And function
virtual FString GetNotifyName_Implementation() const override;
But i am not able to get NotifyName.
I am not sure is it right.

class ANIMGRAPHRUNTIME_API UAnimNotify_PlayMontageNotify : public UAnimNotify
{
GENERATED_UCLASS_BODY()

public:

virtual void BranchingPointNotify(FBranchingPointNotifyPayload& BranchingPointPayload) override;

virtual FString GetNotifyName_Implementation() const override;

#if WITH_EDITOR
virtual bool CanBePlaced(UAnimSequenceBase* Animation) const override;
#endif
protected:

// Name of notify that is passed to the PlayMontage K2Node.
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Notify")
FName NotifyName;

};

The node you looking at is defined at \Engine\Source\Editor\AnimGraph\Public\K2Node_PlayMontage.h

From here you can find out that montage is starting by call on UAnimInstance* - AnimInstance->Montage_Play() so AnimInstance is important; Looking at UAnimInstance code you may find there are two public delegates declared:

	/** Called when a montage hits a 'PlayMontageNotify' or 'PlayMontageNotifyWindow' begin */
	FPlayMontageAnimNotifyDelegate OnPlayMontageNotifyBegin;

	/** Called when a montage hits a 'PlayMontageNotify' or 'PlayMontageNotifyWindow' end */
	FPlayMontageAnimNotifyDelegate OnPlayMontageNotifyEnd;

where delegate is defined as:

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPlayMontageAnimNotifyDelegate, FName, NotifyName, const FBranchingPointNotifyPayload&, BranchingPointPayload);

So just subscribe to it like:

AnimInstance->OnPlayMontageNotifyBegin.AddDynamic(this, &UMyObject::OnNotifyBeginReceived);
AnimInstance->OnPlayMontageNotifyEnd.AddDynamic(this, &UMyObject::OnNotifyEndReceived);

You can get AnimInstance as ACharacter->Mesh->GetAnimInstance()

1 Like

Thank You It worked :+1: :people_hugging: