Skip to main content

Animation Events

Animation events are implemented in the form of a component buffer that is filled by the animation processing engine. Events should be defined in Unity's animation configuration dialog:

AnimationEvents configuration

Animation Event properties are translated into the following component:

public struct AnimationEventComponent: IBufferElementData, IEnableableComponent
{
public uint nameHash;
public float floatParam;
public int intParam;
public uint stringParamHash;
}
  • nameHash - contains a hash value of Unity's animation event Function field. It is calculated by FixedStringExtensions.CalculateHash32() helper function.
  • floatParam - contains authoring animation event Float field.
  • intParam - contains authoring animation event Int field.
  • stringParamHash - contains a hash value of authoring animation event String field. It is calculated by FixedStringExtensions.CalculateHash32() helper function. The Object field of the authoring event is ignored.

In every frame, Rukhanka's animation compute engine fills this buffer with events that occurred in this frame and clears all previous events. So events that occurred in the previous frame are available before RukhankaAnimationSystemGroup. Events occurred in the current frame available after RukhankaAnimationSystemGroup.

Enabling Animation Events

By default, the animation events component buffer is not added to the animated entity. RigDefinitionAuthoring has a checkbox named Has Animation Events which orders to add AnimationEventComponent buffer to the rig entity at the baking stage.

HasAnimationEvents checkbox