Animation Events In Unity

Ben Pielstick
May 29, 2021

--

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.

This is the template you get when creating an animation behavior script

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.

--

--

Ben Pielstick
Ben Pielstick

Written by Ben Pielstick

Game developer with over 12 years of experience, mainly focused on MMOs.

No responses yet