• Yves "Jack" Albuquerque

Basic: Animation Events


We can create Events directly into our animation.

Events are called into the holder Game Object (The one being animated). You should create a method to receive such call.

You can trigger Animation Events for any reason you want, however, some developers prefer to avoid animation events since due debug difficulties (no clues from who is calling the method), others, uses Animation Events only for non-critical task as Play SFX/VFX.

First, you need to know if your animation is read-only(comes from a file) or not.

Read-Only

If the animation is read-only we can use the animation tab at the import settings to associate events to specific animation time. You can use the animation preview to seek the right spot.

An error is returned in case of no receiver, that means, if no method with the same name and params then the one defined here if founded into the animated Game Object.

Read and Write

Otherwise, this can be done directly into the Animation Window (You can duplicate a file animation to turn it editable). On this case, you can select your animated GameObject in order to get a preview directly into the viewport.

Old Unity Versions allows you to specify the method name here as well as showed below.

New Unity versions only shows available methods into the "Function" field into the Inspector.

In our video example, I've created a LFoot and RFoot call into the walk animations, then I used a very simple script that implements both methods to play a footstep SFX.

PS: This example comes directly from the Basic Root Based Movement post.

#Animation #Events #Animator #Feedback