Catch Animation Event from Animation BP in C++

Here is the scenario when I got this issue:

I’m currently implementing the attack animation and hit detection for enemy actors.

At the end of an attack ends, the enemy have to do two things:

1.Set attack animation to unplayable, which can easily done in the animation BP.

2.Clean some of the member variable value in enemy class, which can be done, in my thought, in 2 ways:

   a: call clearvariables() function in animation BP, them implement this function in C++ (this is my current solution)
   b.trigger an animation end notify in animation BP, catch the event and process it in C++ enemy class

I think that the second solution is better, since I can keep it from messing animation BP graph, and keep the
function call in C++ class. The question is, I have no idea how to do it.
If anyone knows how to do it, or even have a better solution for it, I will appreciate your help.

Hello!

For fature referance if anyone would need it.
I do it right now this way:

Crating a BP variable to get the notify from animation.

53463-2015-08-10_082023.png

Create “new notify” with whatever name.

53466-2015-08-10_082908.png

In Animation BP in event graph get the enemy and set created earlier variable to some value on notify- event name.

In Tick function check variable and do some stuff

void MyEnemy::Tick(float deltaTime)
{
	Super::Tick(deltaTime);
	if (bHasPickedArrow)
	{
		//code
	}
}

I know I can communicating between ABP and character C++ class by a variable.

But I still wanna know if I should use it, or any better solution for it.

Got the answer by myself anyway. Here’s the solution:

for( TArray::TIterator it =

GetMesh()->AnimScriptInstance->AnimNotifies.CreateIterator(); it; ++it )

{

 GEngine->AddOnScreenDebugMessage( -1, 15.0f, FColor::Red, (*it)->NotifyName.ToString() );

}

you can use the NofifyName attribute to do the necessary operation you want.

TArray::TIterator

I missed the type

Thank your question and answer, this helps me.