Skip to content

On Animation Event

Detects Animation Events sent to the FSM Component from an AnimationClip.
This action allows the FSM to respond when an animation triggers an event, optionally capturing the parameters sent with it.

Use this to synchronize animations and FSM behavior - for example, triggering effects when a character attacks, plays a sound, or changes states during an animation.

In the Unity Animation window, set the event’s Function to FsmComponent > OnAnimationEvent.

Tip

You can use the FsmComponent > SendEvent(string) to send an event by name to the target FSM.
The main limitation with that method is you can't use parameters. Use On Animtion Event when you need parameters.

Parameters

Parameter Description
Store Float Store the float parameter sent with the AnimationEvent.
Store Integer Store the integer parameter sent with the AnimationEvent.
Store String Store the string parameter sent with the AnimationEvent.
Store Object Store the object reference parameter sent with the AnimationEvent.
Send Event The FSM event to send when the animation event is received.

Tips

Setup in Animation window:

  1. Open the Animation window for your animated object.
  2. Add an Animation Event to the clip timeline.
  3. Set its Function to FsmComponent > OnAnimationEvent.
  4. Optionally specify one of the event parameters (float, int, string, or object).

FSM integration: Use the Send Event parameter to trigger state changes or effects on receipt.

Common Pitfalls

  • Wrong method name: Make sure the function is set to OnAnimationEvent (not onAnimationEvent or similar).
  • Unassigned FSM: The FSM must be on the same GameObject as the animation’s target FsmComponent.
  • No AnimationEvent triggered: Ensure the event exists in the clip and is properly aligned with frames.
  • Object parameter type mismatch: Unity’s objectReferenceParameter only passes references to UnityEngine.Objects (e.g., prefabs, materials, sounds).

See Also