Animation state events

Is there a way I can have animation state events (entered state, left state) in C++?

I was able to get all states from the state machine like this and then I looped through the array to find the state I want by name:



TArray<FBakedAnimationState> states = animInstance->GetStateMachineInstanceFromName("Default")->GetMachineDescription()->States;


but I don’t know how to have an event…

In BP you can put the name of a custom event

img.png
These variables are inside [FONT=courier new]FBakedAnimationState as [FONT=courier new]int32 which seem to be the indexes of [FONT=courier new]FAnimNotifyEvents (that you can edit in the editor as in the print above) in [FONT=courier new]UAnimStateNode.

I think it is impossible to hook up a C++ method to this but it doesn’t hurt asking.

Thanks for any replies!

**EDIT: **looks like [FONT=courier new]GetMachineDescription() is protected, so I can’t use it. Ok, now I’ve lost all hope.

1 Like

same question. I want to deal with these events in C++. My workaround implies to fill out the BP custom events for every single state

  • “EnteredStateEvent”
  • “LeftStateEvent”
  • “FullyBlendedStateEvent”

In the even graph, I put the notes

  • “AnimNotify_EnteredStateEvent”
  • “AnimNotify_LeftStateEvent”
  • “AnimNotify_FullyBlendedStateEvent”

and then I connect every one of these nodes to a blueprint-callable UFunction, implemented in C++, e.g.

  • “HandleEnteredStateEvent”
  • “HandleLeftStateEvent”
  • “HandleFullyBlendedStateEvent”

The first step is the really annoying part. I would like to provide my own Anim State Machine state node to take care of this.