My UAnimNotify custom c++ class Received_Notify won't fire

I’v inserted my native notifier to the animation but when i try to use it, it won’t fire.

This is the header:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "Animation/AnimNotifies/AnimNotify.h"
#include "Enemy_Hit_Notifier.generated.h"

UCLASS()
class OLDSCHOOLNIGHTMARE_API UEnemy_Hit_Notifier : public UAnimNotify
{
	GENERATED_UCLASS_BODY()

	virtual bool Received_Notify(USkeletalMeshComponent* MeshComp, UAnimSequence* AnimSeq) const;
};

This is the source file:

// Fill out your copyright notice in the Description page of Project Settings.

#include "OldSchoolNightmare.h"
#include "Enemy_Hit_Notifier.h"
#include "Enemy_Character.h"


UEnemy_Hit_Notifier::UEnemy_Hit_Notifier(const FObjectInitializer& ObjectInitializer /*= FObjectInitializer::Get()*/)
	: Super(ObjectInitializer)
{
}

bool UEnemy_Hit_Notifier::Received_Notify(USkeletalMeshComponent* MeshComp, UAnimSequence* AnimSeq) const
{
	UE_LOG(LogTemp, Warning, TEXT("Animation Hit Notifying!"));
	AEnemy_Character* character = Cast<AEnemy_Character>(MeshComp->GetOwner());
	character->Hit_Notify();
	return true;
}

It supposed to log “Animation Hit Notifying!”, but it is not logging anything, am i missing something ?

Hi , this code work OK? I Copy/paste but not working… Are you changed someting to do this work?

Since nobody answered i just used blueprint for this one…

, thanks for answering. Im in the same issue now. Can you show me how you did it please?. Or somebody can help me to make this code run?

Thank you. Best regards.

Well, in my case i had main c++ enemy class and blueprint class that inherits from it, so instead of implementing the notify event in c++, i’v made a blueprintevent(in c++) that i can call inside the animationBlueprint, and in the animationBlueprint i triggered this event with the animation notifier that within the blueprint.
this is how it looks like:

animInstanceCPPClass->blueprint_child(with anim notify).

Note that animationBlurprint is actually animationInstance, and this is the class you need to extended in c++ and then make a blueprint child from it.

If i’m not mistaken, this is the type of event you need to implement inside the c++ class:

someHeader:

UFUNCTION( BlueprintImplementableEvent, Category=something)
void event_for_blueprint();

and after you call it from the blueprint, it supposed to activate the function inside the cpp class:

void someHeader::event_for_blueprint()
{
w/e…
}

Hi . After days working, I could fix the problem.

Please take a look:

bool UMyAnimNotifyState::Received_Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) const
{
//	UE_LOG(LogTemp, Warning, TEXT("Animation Hit Notifying!"));
//	AEnemy_Character* character = Cast<AEnemy_Character>(MeshComp->GetOwner());
//	character->Hit_Notify();
	return true;
}


UCLASS()
class BATALLA_API UMyAnimNotifyState : public UAnimNotify
{
	GENERATED_UCLASS_BODY()

//	virtual bool Received_Notify(class USkeletalMeshComponent* MeshComp, class UAnimSequence* AnimSeq) const;
virtual bool Received_Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) const override;

}

This is working perfect to me.

“override” was the keyword.

Thank you.
Best regards.

Omg lol, Thanks for sharing the solution :smiley:

GREAT!!!

Now, if I have the “USkeletalMeshComponent” how can I get the ACharacter ???

bool UMyAnimNotifyState::Received_Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) const
 {
//  ACharacter actor = MeshComp->GetActor();    LOL  LOL  LOL  LOL

//  ACharacter actor = MeshComp->AActor;    LOL  LOL  LOL  LOL
 
     return true;
 }

Thank you, best regards.

SOLVED from your code.

ATropaCharacter* character = Cast<ATropaCharacter>(MeshComp->GetOwner());

Thank you!! Best regards.