Trigger events from animation in Unity

In Unity you do not have to match up an animation with an action by timing it. You can add the event to a set frame on the actual animation. Let’s go over how to implement this.

First, create a script for the animation events and drag it onto the object that has the animation. In this case it is the Player graphics:

The way the animation event works is that it will look for a public function with a name that we will later on add in the inspector. I also added an Action delegate to which the Player class subscribes:

This is what it looks like in the Player script:

Select the animation and check which frame you want to add the event to in the Inspector. If you cannot see the model in the window then you need to drag the FBX file or prefab onto the window:

Open the Animation window and drag the frame counter to the frame where you want the event to get triggered. Name it exactly the same as the function in the script:

Good Luck!

Unity / C# Game developer