Events, just as Curves – are a replacement to the standard Unity events, which can be called in animation. Unlike them, these entities are not attached to animation clip, they are attached to the particular state of AnimationController.
There are two types of Events:
- One shot – standard mechanic. Within limits of normalized time state a point is selected. When state enters that point, this Event is triggered.
- Between – when setting up the even you can select not a point of normalized time state, but a period of it. Unlike One shot, three events wil be called: entering the period, exiting the period, and every update within the period.
Events can also be "guaranteed" and "not guaranteed". "Not guaranteed" events process only the last triggering of the events. Guaranteed events process all events that should have happened since the last frame. This option can be useful if the state is very short, if lag has occured and eaten up a few cycles of states, and you need Event to occur on every of those cycles.
Events offer the following C# events for subscribing to:
- OnStart (only for Between) – occurs on entering current normalized time state in the set period.
- OnFire – triggers upon reaching the normalized time state of the set point, or every frame the given time is inside the set period.
- OnEnd (only for Between) – occurs on exiting current normalized time state from the set period.
- Type – type of a given Event.
- Layer weight tolerance – weight threshold of state layer, after which event starts to trigger.
- Is guaranteed – whether this event is guaranteed or not.
- Value – point or period at which event should trigger.
- State – state, to which the event is attached to.
- Conditional parameter – boolean paramaters which controls whether given Event should trigger.
It's important to understand, that in case of Between Event parameters Layer weight tolerance and Conditional parameter upon changing can cause triggering of OnStart and OnEnd. For example, if the state is located inside the set period and parameter is change from true to false, then OnEnd will be called.