c++ access pawn from AnimNotifyState

Hey Guys,

I’m trying to catch the end of animation for my character and do something in c++ but i cannot acces pawn when notification happens.

 #include "EmreAnimNotifyState.h"
 UEmreAnimNotifyState::UEmreAnimNotifyState(const class FObjectInitializer& PCIP) : Super(PCIP) {
     UE_LOG(LogEmre, Warning, TEXT("emre: %s"), TEXT("initialized"));
 void UEmreAnimNotifyState::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration) {
     Super::NotifyBegin(MeshComp, Animation, TotalDuration);
     UE_LOG(LogEmre, Warning, TEXT("emre: %s"), TEXT("the start"));
 void UEmreAnimNotifyState::NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation) {
     Super::NotifyEnd(MeshComp, Animation);
     UE_LOG(LogEmre, Warning, TEXT("emre: %s"), TEXT("the end"));

This is the code i have for end of the notification which i don’t know hot to call my pawn simply or on initialization set the pawn reference to this class/object somehow? i don’t wanna iterate over all players/pawns/actors to find the right one there should be a way to access directly the pawn or current character that we play. If there is a better way to do the animation and catch the ending of it in c++ i’m open for that aswell.

You can just call GetOwner() on the MeshComp argument, and cast to your pawn class.

i guess i tried that and causing some problems on compile time.

i cannot access pawn due to …

Found solution: How to get Character within UAnimNotify - Character & Animation - Unreal Engine Forums

i had to do null check before try to access my pawn because this function might be called from editor when no pawn initialized…

This is how I do it in my code, so it should work on your end.

thanks figured it out by debugging :), anyway helped me alot thank you!