Animation Events

Another parameter we can assign to an animation is the Animation Event. This allows you to call a specific function or action from within the animation. For example, let’s say you have a door with a light that activates when the door is shut and locked. You might have a script that makes the light active and plays an audio effect of locking. One method for calling the script could be to set it as an Animation Event in the door animation.

While we won’t go into Animation Events in great detail here, creating them is simple enough. In the Animation window, right-click in the timeline and select Add Animation Event. You can also click the Add Event button that sits directly above the Sample value.

Tip

In order for an Animation ...

Get Learning 2D Game Development with Unity®: A Hands-On Guide to Game Creation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.