UAnimInstance::AddNativeStateExitBinding
#include "Animation/AnimInstance.h"
Access: public
Specifiers: ENGINE_API
Description
Binds a native C++ delegate that fires when the specified state in an animation state machine is exited. Use this for cleanup or transition logic that should run when leaving a particular state.
Caveats & Gotchas
- • The delegate fires once per exit. If the state is exited and immediately re-entered (e.g., a same-frame transition loop), both the exit and entry delegates fire in sequence.
- • Register bindings in NativeInitializeAnimation. State and machine names must match the Animation Blueprint graph exactly (case-sensitive).
Signature
ENGINE_API void AddNativeStateExitBinding(const FName& MachineName, const FName& StateName, const FOnGraphStateChanged& NativeExitedDelegate, const FName& BindingName = NAME_None) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| MachineName | const FName& | Name of the state machine containing the state. | — |
| StateName | const FName& | Name of the state to bind exit notification to. | — |
| NativeExitedDelegate | const FOnGraphStateChanged& | Delegate to call when the state machine exits this state. | — |
| BindingName | const FName& | Optional name to identify this binding for later queries. | NAME_None |
Return Type
void Example
Stop a looping effect when leaving a state C++
void UMyAnimInstance::NativeInitializeAnimation()
{
Super::NativeInitializeAnimation();
FOnGraphStateChanged ExitDelegate;
ExitDelegate.BindUObject(this, &UMyAnimInstance::OnExitChargeState);
AddNativeStateExitBinding(FName("Combat"), FName("Charging"), ExitDelegate);
}
void UMyAnimInstance::OnExitChargeState(const FAnimNode_StateMachine& Machine, int32 PrevStateIndex, int32 NextStateIndex)
{
if (ChargeEffect) { ChargeEffect->Deactivate(); }
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?