How to do it...

To use Animation Events to trigger script functions, follow these steps:

  1. Import your character with the HumanAttack animation to Unity.
  2. Go to the Animation import settings tab in the Inspector window.
  3. Select the HumanAttack animation.
  4. Navigate down to the Events section and unfold it.
  5. Use the Preview window to scrub through the animation to the moment of the hit in the attack.
  1. Add an Animation Event by pressing the Add Event button, as shown in the following screenshot:
Adding Animation Events
  1. The Edit Animation Event window will appear. Type Attack in the Function text field. To make the event work, we need to have a ...

Get Unity 5.x Animation Cookbook 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.