Animation Events In Unity
While most of the time events are driven by gameplay, there are also times when something needs to happen based on an animation. This can be things like playing sounds or particle effects, or even triggering gameplay actions, depending on the style of game.
Unity makes this possible through StateMachineBehaviour scripts, that come pre-populated with a set of methods if created via the animator editor.
By listening for this set of state changes, we can easily add events based on animations. Each one also provides the Animator being listened to, which gives us access to the game object playing the animations, which is often important for performing actions based on animations.